Added contains functions in List and Option. Fixed one type error catch

This commit is contained in:
radrow
2020-08-26 11:56:18 +02:00
parent ed5447e430
commit 7e32ef57c2
4 changed files with 32 additions and 7 deletions
+6 -2
View File
@@ -15,10 +15,14 @@ namespace List =
_::t => Some(t)
function last(l : list('a)) : option('a) = switch(l)
[] => None
[x] => Some(x)
[] => None
[x] => Some(x)
_::t => last(t)
function contains(e : 'a, l : list('a)) = switch(l)
[] => false
h::t => h == e || contains(e, t)
/** Finds first element of `l` fulfilling predicate `p` as `Some` or `None`
* if no such element exists.
*/