feat: improve reduction algorithm with LIFO-based iterator #15

Merged
mvhutz merged 7 commits from feat/lifo-improvements into main 2026-01-12 02:16:07 +00:00
6 changed files with 5 additions and 92 deletions
Showing only changes of commit 35224ee4d7 - Show all commits

View File

@@ -51,11 +51,11 @@ func runSample(samplePath string) error {
// Benchmark all samples using sub-benchmarks. // Benchmark all samples using sub-benchmarks.
func BenchmarkSamples(b *testing.B) { func BenchmarkSamples(b *testing.B) {
samples := map[string]string{ samples := map[string]string{
"Church": "../../samples/church.txt", "Church": "../../samples/church.test",
"Fast": "../../samples/fast.txt", "Fast": "../../samples/fast.test",
"Saccharine": "../../samples/saccharine.txt", "Saccharine": "../../samples/saccharine.test",
"Simple": "../../samples/simple.txt", "Simple": "../../samples/simple.test",
"Thunk": "../../samples/thunk.txt", "Thunk": "../../samples/thunk.test",
} }
for name, path := range samples { for name, path := range samples {

View File

@@ -1,7 +0,0 @@
0 := \f.\x.x
inc n := \f x.(f (n f x))
exp n m := (m n)
N := (inc (inc (inc (inc (inc (inc 0))))))
(exp N N)

View File

@@ -1,11 +0,0 @@
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)

View File

@@ -1,52 +0,0 @@
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)

View File

@@ -1,16 +0,0 @@
(\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
)

View File

@@ -1 +0,0 @@
(\.VALUE anything)