fix: correct gitignore pattern to only exclude root binary

Changed 'lambda' to '/lambda' in .gitignore to prevent accidentally
hiding files in pkg/lambda/ directory. The pattern now correctly
excludes only the compiled binary at the repository root.

Also adds previously hidden pkg/lambda/iterator.go to the repository.
This commit is contained in:
2026-01-11 20:21:15 -05:00
parent d4f33c1658
commit da9ee0bcb0
2 changed files with 60 additions and 1 deletions

59
pkg/lambda/iterator.go Normal file
View File

@@ -0,0 +1,59 @@
package lambda
type Iterator struct {
trace []*Expression
}
func NewIterator(expr *Expression) *Iterator {
return &Iterator{
trace: []*Expression{expr},
}
}
func (i *Iterator) Current() *Expression {
if len(i.trace) < 1 {
return nil
}
return i.trace[len(i.trace)-1]
}
func (i *Iterator) Parent() *Expression {
if len(i.trace) < 2 {
return nil
}
return i.trace[len(i.trace)-2]
}
func (i *Iterator) Next() {
switch typed := (*i.Current()).(type) {
case *Abstraction:
i.trace = append(i.trace, &typed.body)
case *Application:
i.trace = append(i.trace, &typed.abstraction)
case *Variable:
for len(i.trace) > 1 {
if app, ok := (*i.Parent()).(*Application); ok {
if app.abstraction == *i.Current() {
i.Back()
i.trace = append(i.trace, &app.argument)
return
}
}
i.Back()
}
i.trace = []*Expression{}
}
}
func (i *Iterator) Back() bool {
if len(i.trace) == 0 {
return false
}
i.trace = i.trace[:len(i.trace)-1]
return true
}