Merge branch 'lima' into master
This commit is contained in:
@@ -15,8 +15,8 @@ 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 drop_last(l : list('a)) : option(list('a)) = switch(l)
|
||||
@@ -28,6 +28,11 @@ namespace List =
|
||||
h::t => h::drop_last_unsafe(t)
|
||||
[] => abort("drop_last_unsafe: list empty")
|
||||
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
@@ -22,7 +22,11 @@ namespace Option =
|
||||
|
||||
/** Assume it is `Some`
|
||||
*/
|
||||
function force(o : option('a)) : 'a = default(abort("Forced None value"), o)
|
||||
function force(o : option('a)) : 'a = switch(o)
|
||||
None => abort("Forced None value")
|
||||
Some(x) => x
|
||||
|
||||
function contains(e : 'a, o : option('a)) = o == Some(e)
|
||||
|
||||
function on_elem(o : option('a), f : 'a => unit) : unit = match((), f, o)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user