Kind/book/List.find.kind2
2024-03-01 20:40:31 -03:00

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)