mirror of
https://github.com/HigherOrderCO/Kind.git
synced 2024-09-11 19:37:08 +03:00
17 lines
562 B
Plaintext
17 lines
562 B
Plaintext
BBT.get
|
|
: ∀(K: *)
|
|
∀(V: *)
|
|
∀(cmp: ∀(a: K) ∀(b: K) Cmp)
|
|
∀(key: K)
|
|
∀(map: (BBT K V))
|
|
(Maybe V)
|
|
= λK λV λcmp λkey λmap
|
|
let P = λx(Maybe V)
|
|
let bin = λ_size λnext.key λnext.val λnext.lft λnext.rgt
|
|
let P = λx ∀(cmp: ∀(a: K) ∀(b: K) Cmp) ∀(key: K) (Maybe V)
|
|
let ltn = λcmp λkey (BBT.get K V cmp key next.lft)
|
|
let eql = λcmp λkey (Maybe.some V next.val)
|
|
let gtn = λcmp λkey (BBT.get K V cmp key next.rgt)
|
|
((~(cmp key next.key) P ltn eql gtn) cmp key)
|
|
let tip = (Maybe.none V)
|
|
(~map P bin tip) |