diff --git a/cmd/lambda/benchmark_test.go b/cmd/lambda/benchmark_test.go index eec47df..72fd5b6 100644 --- a/cmd/lambda/benchmark_test.go +++ b/cmd/lambda/benchmark_test.go @@ -51,11 +51,11 @@ func runSample(samplePath string) error { // Benchmark all samples using sub-benchmarks. func BenchmarkSamples(b *testing.B) { samples := map[string]string{ - "Church": "../../samples/church.test", - "Fast": "../../samples/fast.test", - "Saccharine": "../../samples/saccharine.test", - "Simple": "../../samples/simple.test", - "Thunk": "../../samples/thunk.test", + "Church": "../../tests/church.test", + "Fast": "../../tests/fast.test", + "Saccharine": "../../tests/saccharine.test", + "Simple": "../../tests/simple.test", + "Thunk": "../../tests/thunk.test", } for name, path := range samples { diff --git a/samples/church.txt b/samples/church.txt new file mode 100644 index 0000000..571d394 --- /dev/null +++ b/samples/church.txt @@ -0,0 +1,7 @@ +0 := \f.\x.x +inc n := \f x.(f (n f x)) +exp n m := (m n) + +N := (inc (inc (inc (inc (inc 0))))) + +(exp N N) diff --git a/samples/fast.txt b/samples/fast.txt new file mode 100644 index 0000000..3c84b21 --- /dev/null +++ b/samples/fast.txt @@ -0,0 +1,11 @@ +fix f := (\x.(f (x x)) \x.(f (x x))) + +inc := (fix \self.\l.(((l \x.\y.x) ((((l \x.\y.y) \x.\y.x) \c.((c \x.\y.x) \c.((c \x.\y.y) (self ((l \x.\y.y) \x.\y.y))))) \c.((c \x.\y.x) \c.((c \x.\y.x) ((l \x.\y.y) \x.\y.y))))) \c.((c \x.\y.x) \c.((c \x.\y.x) \VAR0.\x.\y.y)))) +one := \c.((c \x.\y.x) \c.((c \x.\y.x) \VAR0.\x.\y.y)) +double := \N.\c.((c \x.\y.x) \c.((c \x.\y.y) N)) +print := (fix \self.\l.(((l \x.\y.x) (((((l \x.\y.y) \x.\y.x) 1) 0) (self ((l \x.\y.y) \x.\y.y)))) END)) + + +N := \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.y) \c.((c \x.\y.x) \c.((c \x.\y.x) \VAR0.\x.\y.y)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) + +(print N) diff --git a/samples/saccharine.txt b/samples/saccharine.txt new file mode 100644 index 0000000..10584cf --- /dev/null +++ b/samples/saccharine.txt @@ -0,0 +1,52 @@ +T x y := x +F x y := y +if b t e := (b t e) + +pair a b := \c.(c a b) +left p := (p T) +right p := (p F) + +print n := (n 0 1 end) + +fix f := (\x.(f (x x)) \x.(f (x x))) + +some x := (pair T x) +none := \.F +isfull := left +unwrap := right + +nil := none +push i l := (some (pair i l)) +peek l := (left (unwrap l)) +pop l := (right (unwrap l)) + +inc := (fix \self l.{ + (if (isfull l) + (if (peek l) + (push F (self (pop l))) + (push T (pop l)) + ) + (push T nil) + ) +}) + +print := (fix \self l.{ + (if (isfull l) + ((if (peek l) 1 0) (self (pop l))) + END + ) +}) + +one := (push T nil) +double N := (push F N) + +N := + (double (double (double (double (double + (double (double (double (double (double + (double (double (double (double (double + (double (double (double (double (double + (double (double (double (double (double + (double (double (double (double (double + one)))))))))))))))))))))))))))))) + +(print N) diff --git a/samples/simple.txt b/samples/simple.txt new file mode 100644 index 0000000..192f069 --- /dev/null +++ b/samples/simple.txt @@ -0,0 +1,16 @@ +(\0. + (\inc. + (\add. + (\mult. + (\exp. + (exp (inc (inc (inc (inc 0)))) (inc (inc (inc (inc (inc 0)))))) + \n m.(m n) + ) + \m n f.(m (n f)) + ) + \n m.(m inc n) + ) + \n f x.(f (n f x)) + ) + \f x.x +) diff --git a/samples/thunk.txt b/samples/thunk.txt new file mode 100644 index 0000000..4181291 --- /dev/null +++ b/samples/thunk.txt @@ -0,0 +1 @@ +(\.VALUE anything) \ No newline at end of file