The repository contains a TRAC interpreter described in the book Etudes for Programmers (1978) by Charles Wetherell.
The interpreter is written in JavaScript and implements what is called the original TRAC-64 definition of the language.
To run the interpreter, you need either node (24+), bun or deno.
The interpreter also implements additional functions and an ability to call forms as functions by name, suggested by Charles Wetherell as an extension of the etude.
All functions are covered by unit tests.
NOTE: However, there are a few unimplemented functions: external stream I/O (ai, ao, sp, rp) and external block I/O (sb, fb, eb).
node trac.ts examples/e.trac
2.7182818277node trac.ts examples/pi.trac
3.1415926538node trac.ts examples/factorial.trac
30414093201713378043612608166064768844377641568960512000000000000node trac.ts examples/hanoi.trac
from 1 to 3
from 1 to 2
from 3 to 2
from 1 to 3
from 2 to 1
from 2 to 3
from 1 to 3node trac.ts examples/rule_110.trac
...............1...............
..............11...............
.............111...............
............11.1...............
...........11111...............
..........11...1...............
.........111..11...............
........11.1.111...............
.......1111111.1...............
......11.....111...............
.....111....11.1...............It is possible to run TRAC programs directly from the command line by prefixing command line arguments with @.
node trac.ts "@#(ps,I am TRAC)'"
I am TRACnode trac.ts
TRAC interpreter (CTRL-C or #(hl)' to exit)
TRAC>Then you can type TRAC code interactively.
bun test