mirror of
https://github.com/HigherOrderCO/Kind.git
synced 2024-10-26 16:20:58 +03:00
16 lines
365 B
Plaintext
16 lines
365 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)
|