lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi!

Inspired by Steve Donovan's recent work, I made this:
https://github.com/petrihakkinen/f

It's a Forth interpreter that can be used as a command line calculator on Unix-like shells. It's also good for generating Mandelbrot as ASCII art,  check the github page for proof :)

Why Forth? Forth is my second favorite programming language (guess what is the first?) and its lack of syntax works well with the trigger-happy substitutions performed by most shells (Steve knows what I'm talking about!).

Below are some examples.

f is written 100% in Lua.

Petri


> f 10 2 * 5 +    ( calculate 10 * 2 + 5 )
25

> f pi 2 / sin
1.0

> f ascii *    ( print the ascii value of * )
42

> f 1024 hex    ( convert 1024 from decimal to hex )
400

> f hex 1000 decimal    ( convert 1000 from hex to decimal )
4096

> f : square dup *    ( add a new word to dictionary )

> cat .f    ( dictionary is automatically saved to file named .f )
: square dup * ;

> f 5 square    ( init file is loaded automatically so all previously defined words can be used )
25