-
Notifications
You must be signed in to change notification settings - Fork 442
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change examples test to read from examples directory
- Loading branch information
Showing
11 changed files
with
140 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
data Bool = True | False | ||
|
||
data Tree | ||
= (Node lft rgt) | ||
| (Leaf val) | ||
|
||
and True True = True | ||
and _ _ = False | ||
|
||
all (Node lft rgt) = (and (all lft) (all rgt)) | ||
all (Leaf val) = val | ||
|
||
main = (all (gen 8)) | ||
|
||
gen = λn switch n { | ||
0: (Leaf True) | ||
_: let tree = (gen n-1); (Node tree tree) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
T = λt λf t | ||
F = λt λf f | ||
And = λpλq (p q F) | ||
|
||
Z = λs λz (z) | ||
S = λn λs λz (s n) | ||
|
||
Add = λa λb (a (S b)) | ||
Mul = λa λb λf (a (b f)) | ||
Pow = λa λb (a (Mul b) (S Z)) | ||
|
||
Node = λa λb λn λl (n a b) | ||
Leaf = λn λl l | ||
|
||
Alloc = λn (n (λp (Node (Alloc p) (Alloc p))) Leaf) | ||
Destroy = λt (t (λaλb (And (Destroy a) (Destroy b))) T) | ||
|
||
Main = (Destroy (Alloc (Pow (S (S Z)) (S (S (S (S Z))))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
add = λa λb (+ a b) | ||
|
||
fib = λx switch x { | ||
0: 1 | ||
_: let p = x-1; switch p { | ||
0: 1 | ||
_: (+ (fib p) (fib p-1)) | ||
} | ||
} | ||
|
||
main = (fib 30) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
_Char = 0 | ||
_List = λ_T 0 | ||
_List.cons = λ_head λ_tail λ_P λ_cons λ_nil ((_cons _head) _tail) | ||
_List.nil = λ_P λ_cons λ_nil _nil | ||
_Nat = 0 | ||
_Nat.succ = λ_n λ_P λ_succ λ_zero (_succ _n) | ||
_Nat.zero = λ_P λ_succ λ_zero _zero | ||
_String = (_List _Char) | ||
_String.cons = λ_head λ_tail λ_P λ_cons λ_nil ((_cons _head) _tail) | ||
_String.nil = λ_P λ_cons λ_nil _nil | ||
_Tree = λ_A 0 | ||
_Tree.gen = λ_n λ_x switch _n = _n { 0: _Tree.leaf _: let _n-1 = _n-1 (((_Tree.node _x) ((_Tree.gen _n-1) (+ (* _x 2) 1))) ((_Tree.gen _n-1) (+ (* _x 2) 2))) } | ||
_Tree.leaf = λ_P λ_node λ_leaf _leaf | ||
_Tree.node = λ_val λ_lft λ_rgt λ_P λ_node λ_leaf (((_node _val) _lft) _rgt) | ||
_main = ((_Tree.gen 8) 2) | ||
|
||
main = _main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// size = 1 << 8 | ||
|
||
Mul = λn λm λs (n (m s)) | ||
|
||
// Church nat | ||
C2 = λf λx (f (f x)) | ||
|
||
// Church powers of two | ||
P2 = (Mul C2 C2) // 4 | ||
P3 = (Mul C2 P2) // 8 | ||
P4 = (Mul C2 P3) // 16 | ||
P5 = (Mul C2 P4) // 32 | ||
P6 = (Mul C2 P5) // 64 | ||
P7 = (Mul C2 P6) // 128 | ||
P8 = (Mul C2 P7) // 256 | ||
|
||
// Booleans | ||
True = λt λf t | ||
False = λt λf f | ||
Not = λb ((b False) True) | ||
Neg = λb λt λf (b f t) | ||
|
||
// Negates 'true' 256 times: 'neg' is faster than 'not' because it fuses | ||
Main = (P8 Neg True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
source: tests/golden_tests.rs | ||
input_file: examples/callcc.hvm | ||
--- | ||
52 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
source: tests/golden_tests.rs | ||
input_file: examples/example.hvm | ||
--- | ||
8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
source: tests/golden_tests.rs | ||
input_file: examples/fusing_add.hvm | ||
--- | ||
λa λb λ* (b λc λ* (c a)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
source: tests/golden_tests.rs | ||
input_file: examples/fusing_not.hvm | ||
--- | ||
λa λb λc (a b c) |