All Projects → zhiayang → lambda

zhiayang / lambda

Licence: Apache-2.0 license
lambda calculus interpreter

Programming Languages

C++
36643 projects - #6 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to lambda

Plam
An interpreter for learning and exploring pure λ-calculus
Stars: ✭ 385 (+1573.91%)
Mutual labels:  lambda, interpreter, lambda-calculus
Aws Lambda Workshop
Some incremental examples suitable to host an AWS Lambda Functions workshop
Stars: ✭ 18 (-21.74%)
Mutual labels:  lambda, lambda-calculus
Go Pry
An interactive REPL for Go that allows you to drop into your code at any point.
Stars: ✭ 2,747 (+11843.48%)
Mutual labels:  interpreter, repl
Lambda
Fun with λ calculus!
Stars: ✭ 65 (+182.61%)
Mutual labels:  lambda, lambda-calculus
Charly
🐈 The Charly Programming Language | Written by @KCreate
Stars: ✭ 185 (+704.35%)
Mutual labels:  interpreter, repl
Codi.vim
📔 The interactive scratchpad for hackers.
Stars: ✭ 2,464 (+10613.04%)
Mutual labels:  interpreter, repl
Minimal
A Delightfully Diminutive Lisp. Implemented in < 1 KB of JavaScript with JSON source, macros, tail-calls, JS interop, error-handling, and more.
Stars: ✭ 560 (+2334.78%)
Mutual labels:  lambda, interpreter
charm
A [ functional stack ] based language.
Stars: ✭ 26 (+13.04%)
Mutual labels:  interpreter, repl
fundot
The Fundot programming language.
Stars: ✭ 15 (-34.78%)
Mutual labels:  interpreter, repl
StepULC
Efficient and single-steppable ULC evaluation algorithm
Stars: ✭ 15 (-34.78%)
Mutual labels:  interpreter, lambda-calculus
Janet
A dynamic language and bytecode vm
Stars: ✭ 2,216 (+9534.78%)
Mutual labels:  interpreter, repl
klisp
A Lisp written in about 200 lines of Ink, featuring an interactive literate programming notebook
Stars: ✭ 28 (+21.74%)
Mutual labels:  interpreter, repl
Gomacro
Interactive Go interpreter and debugger with REPL, Eval, generics and Lisp-like macros
Stars: ✭ 1,784 (+7656.52%)
Mutual labels:  interpreter, repl
Mond
A scripting language for .NET Core
Stars: ✭ 237 (+930.43%)
Mutual labels:  interpreter, repl
Brain
An esoteric programming language compiler on top of LLVM based on Brainfuck
Stars: ✭ 112 (+386.96%)
Mutual labels:  interpreter, repl
Endbasic
BASIC environment with a REPL, a web interface, and RPi support written in Rust
Stars: ✭ 106 (+360.87%)
Mutual labels:  interpreter, repl
Mikrokosmos
(λ) Educational lambda calculus interpreter
Stars: ✭ 50 (+117.39%)
Mutual labels:  interpreter, lambda-calculus
Goto
Goto is an interpreted programming language written in go.
Stars: ✭ 79 (+243.48%)
Mutual labels:  interpreter, repl
Portkey
Live-coding the Cloud
Stars: ✭ 139 (+504.35%)
Mutual labels:  lambda, repl
endbasic
BASIC environment with a REPL, a web interface, a graphical console, and RPi support written in Rust
Stars: ✭ 220 (+856.52%)
Mutual labels:  interpreter, repl

lambda calculus interpreter

what:

A small lambda calculus interpreter written in C++. It supports α-conversion and β-reduction, as well as precise tracing output of replacements and renames.

how:

The standard lambda calculus syntax is supported, eg:

(λz.(((λx.(λy.x)) z) ((λx.(λy.x)) z)))

Note that variable names can be multi-character, so they must be separated with spaces. Syntax sugar for multi-argument functions is supported:

λx y.x == λx.λy.x

Haskell-style lambda syntax is also supported, because nobody knows how to type λ:

\x y -> x == \x -> \y -> x

Let-bindings are also supported:

let S = \x y z -> x z (y z)
let K = \x y -> x
let I = \x -> x

S K K == I

If the FLAG_VAR_REPLACEMENT flag (toggle with :v) is used, the interpreter will attempt to back-substitute the end result of an evaluation by using alpha-equivalence; for example, when doing S K K, instead of showing λx.x, it will show I if an alpha-equivalent definition of I is available.

load

You can load files from the command line simply by passing them as arguments to the interpreter, eg.

$ build/lc lib/ski.lc

You can also use the :load directive, either in the REPL or in a file itself (so you can do recursive includes). Note that include loops are not handled, and you'll crash the interpreter.

example

Here is some example output:

*. parenthesis omission enabled
*. curried abbreviation enabled
*. haskell-style printing enabled
*. loaded 13 lines from 'lib/ski.lc'
λ> S K K
0. (\x y z -> x z (y z)) (\x y -> x) (\x y -> x)
1. β-red: x <- (\x y -> x)
2. β-red: y <- (\x y -> x)
3. β-red: x <- z
4. β-red: y <- (\x y -> x) z
*. done.
(\z -> z)

λ>

repl commands

command function
:q quit the repl
:t enable (basic) tracing (shows α and β steps)
:ft enable full tracing (detailed substitution)
:v enable back-substitution for the result
:p enable omitting unambiguous parentheses when printing
:c enable shorthand notation when printing curried functions
:h enable haskell-style notation when printing
:load load a file (eg. :load foo.lc) and add it to the context
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].