For now, we recommend our JavaScript implementation:

  1. Download and install Node.js®
  2. Download our latest tree calculus evaluator, a self-contained JavaScript app (see here for CLI help)
  3. Download the latest LambAda compiler, a tree that turns lightweight notation into trees


Examples:

# Applying the identity tree (passed as a term or ternary) to various data:
$ ./main.js -term '△ (△ (△ △)) △' -string 'hello world'
hello world
$ ./main.js -ternary 21100 -nat 42
42
$ ./main.js -ternary 21100 -nat 42 -term # override return value format
△ △ ((△ △) (△ △ ((△ △) (△ △ ((△ △))))))

# Using the LambAda compiler to parse lambda syntax
$ ./main.js -dag -file compile.dag -string '\x x' -ternary
21100
$ ./main.js -dag -file compile.dag -string '\x \f f x' -ternary          
2120112110010
$ ./main.js -dag -file compile.dag -string '\x x' -nat 42
42
$ ./main.js -dag -file compile.dag -string '\x \y x' -nat 42 -nat 1337
42
$ ./main.js -dag -file compile.dag -string '\x \y y' -nat 42 -nat 1337
1337
$ ./main.js -dag -file compile.dag -string '\hd △ hd "ello World"' -nat 72 -string
Hello World


Using the interactive playground: We strongly recommend exploring the demos (look for 🚀) from the landing page in our interactive playground. Notably, this demo demonstrates core capabilities of tree calculus and includes a ternary encoder (section 3) that you can use to export more complex functions for use with the CLI above.


A more involved example: A program that measures the size (number of tree nodes) of its argument.

1. Paste the following into the interactive playground, clearing out all previous code.


wait = \a \b \c  ( a) (  c) b
compose = \f \g \x f (g x)
m = \x x x
fix = \f wait m (\x f (wait m x))
triage = \a \b \c  ( a b) c
succ = fix $ \self triage 1  (triage ( $  ) (\_ \tl   $ self tl) )
to_ternary = \x (fix $ \self \x \rest triage ( '0') (\x \rest  '1' $ self x rest) (\x \y \rest  '2' $ self x $ self y rest) x rest) x 

size = \x (fix $ \self \x compose succ $ triage (\x x) self (\x \y compose (self x) (self y)) x) x 0
to_ternary size

2. Copy the resulting ternary string 212121... into a file, say size.ternary.

3. Use the size program from the CLI:

# Sanity checks
$ ./main.js -ternary -file size.ternary -term '△' -nat     # 1
$ ./main.js -ternary -file size.ternary -term '△ △' -nat   # 2
$ ./main.js -ternary -file size.ternary -term '△ △ △' -nat # 3
# Calculate the size of the size program or compiler
$ ./main.js -ternary -file size.ternary -ternary -file size.ternary -nat
$ ./main.js -ternary -file size.ternary -dag -file compile.dag -nat