mirror of
https://github.com/HigherOrderCO/Kind.git
synced 2024-10-03 18:27:13 +03:00
some fixes and add BMap data structure
This commit is contained in:
parent
56ec0f7951
commit
78fc259958
3
book/BMap.kind2
Normal file
3
book/BMap.kind2
Normal file
@ -0,0 +1,3 @@
|
||||
data BMap A
|
||||
| node (lft: (BMap A)) (val: A) (rgt: (BMap A))
|
||||
| leaf
|
3
book/BMap/leaf.kind2
Normal file
3
book/BMap/leaf.kind2
Normal file
@ -0,0 +1,3 @@
|
||||
BMap.leaf
|
||||
: ∀(A: *) (BMap A)
|
||||
= λA ~λP λnode λleaf leaf
|
After Width: | Height: | Size: 61 B |
8
book/BMap/node.kind2
Normal file
8
book/BMap/node.kind2
Normal file
@ -0,0 +1,8 @@
|
||||
BMap.node
|
||||
: ∀(A: *)
|
||||
∀(lft: (BMap A))
|
||||
∀(val: A)
|
||||
∀(rgt: (BMap A))
|
||||
(BMap A)
|
||||
= λA λlft λval λrgt
|
||||
~λP λnode λleaf (node lft val rgt)
|
After Width: | Height: | Size: 153 B |
@ -12,3 +12,8 @@ Monad
|
||||
(P (Monad/new M bind pure))
|
||||
)
|
||||
(P self)
|
||||
|
||||
//data Monad (M: * -> *)
|
||||
//| new
|
||||
//(bind: ∀(A: *) ∀(B: *) ∀(a: (M A)) ∀(b: ∀(a: A) (M B)) (M B))
|
||||
//(pure: ∀(A: *) ∀(a: A) (M A))
|
||||
|
@ -6,6 +6,6 @@ is_gtn (a: Nat) (b: Nat) : Bool =
|
||||
zero: false
|
||||
succ: match b {
|
||||
zero: true
|
||||
succ: (gtn a.pred b.pred)
|
||||
succ: (is_gtn a.pred b.pred)
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,6 @@ is_ltn (a: Nat) (b: Nat) : Bool =
|
||||
}
|
||||
succ: match b {
|
||||
zero: false
|
||||
succ: (ltn a.pred b.pred)
|
||||
succ: (is_ltn a.pred b.pred)
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use Nat/{succ,zero}
|
||||
use Bool/{true,false}
|
||||
|
||||
is_ltn_or_eql (a: Nat) (b: Nat) : Bool =
|
||||
match _ = (Nat/ltn a b) {
|
||||
match _ = (Nat/is_ltn a b) {
|
||||
true: true
|
||||
false: (Nat/equal a b)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user