Skip to content
No description, website, or topics provided.
Elixir Forth
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
lib
test
.formatter.exs
.gitignore
license.txt
mix.exs
readme.txt
test.fs

readme.txt

Forth interpreter

Usage:
  invoke:
  mix forth
  ? is prompt

  define word:
  ? : plus + ;
  ok

  read file:
  include test.fs
  ok

  constant:
  ? 3 value a
  ok
  ? a 3 * .
  9 ok

  variable:
  ? variable x
  ok
  ? 3 x !
  ok
  ? x @ .
  3 ok
  ?


  quit:
  ? bye

Example:
mix forth
Forth in Elixir
? 1 2 + .
3 ok
? : square dup * ;
ok
? 3 square .
ok
9 ok
? : fib 0 1 rot 0 ?do over + swap loop drop ;
? 10 fib .
55 ok
? bye
May the Force be with you bye
true

recursive:
word recursive or recurse is not necessary
: fac ( n -- factorial )
    dup 1 > if
      dup 1 - fac *
    else
      drop 1
    endif ;
You can’t perform that action at this time.