mirror of
https://github.com/HigherOrderCO/Kind.git
synced 2024-09-11 20:47:25 +03:00
13 lines
353 B
Plaintext
13 lines
353 B
Plaintext
List.find
|
|
: ∀(A: *) ∀(cond: ∀(x: A) Bool) ∀(list: (List A))
|
|
(Maybe A)
|
|
= λA λcond λlist
|
|
let P = λx (Maybe A)
|
|
let cons = λhead λtail
|
|
let found = (cond head)
|
|
let P = λx (Maybe A)
|
|
let true = (Maybe.some A head)
|
|
let false = (List.find A cond tail)
|
|
(~found P true false)
|
|
let nil = (Maybe.none A)
|
|
(~list P cons nil) |