Lambda interpreter built in Scala. Supports AST View, CbN, CbV and Free Variables calculations.
- "λ": The lambda symbol represents the beginning of an abstraction.
- " ": The space allows for separating the argument from the function in an application.
- ".": The dot allows for separating the argument from the body of an abstraction.
- "(": The left parenthesis allows for representing the beginning of an application.
- ")":" The right parenthesis allows for representing the end of an application.
- string: Any other string, different from the ones above, will be interpreted as a variable.
-
The Lambda expression must follow the syntax structure defined as:
<λexp> ::=
<var>
#Variable<LAMBDA> <var> <DOT> <λexp>
#Abstraction<LPAR> <λexp> <SPACE> <λexp> <RPAR>
#Application
-
set <reduction strategy>
set call-by-name
(default strategy)set call-by-value
set free-variables
-
exit
Expression | Call-by-Name Result | Call-by-Value Result |
---|---|---|
(λx.λy.y (λx.(x x) λx.(x x))) |
λy.y |
Infinite recursion |
(λx.λx.(y x) z) |
λx.(y x) |
λx.(y x) |
(λx.λy.x y) |
λy*.y |
λy*.y |
(λy.λb.b ((λf.λb.f b) b)) |
λb*.b* |
λb*.b* |
(λf.(f λx.λy.x) ((λx.λy.λf.((f x) y) a) b)) |
a |
a |
- Add boolean and arithmetic expressions support
The project uses Scala 3.3.3 and sbt.
For running the program open the sbt interpreter using:
sbt
- Compile with:
compile
- And execute with:
run
- For exiting the program:
exit
Note: If you run the project on Windows, use the symbol "/" instead of the symbol "λ" as PowerShell does not support it.