I wanted to play around with Stevan Apter's F programming language:
http://nsl.com/k/f/f.htmBut I don't have a K interpreter. F is very similar to XY so I started
hacking my JavaScript version of XY to do it. But then I wanted to run
it on a low spec portable device with very little memory so I ended up
writing a little C++ interpreter. It's very simple. Doesn't do any
optimisations and manages the stack and queue as described by Stevan's
programming documents. I've placed the source on github:
http://github.com/doublec/cf/tree/masterI'm not really intending it to be a 'programming language', just an
easy body of code to hack around ideas with. Hopefully it's useful for
others to play around with too. It's implemented in one C++ file for
simplicity:
http://tinyurl.com/c4bmj6This is the prelude which contains some examples - based on Stevan's F prelude:
http://tinyurl.com/crd4kuThere are a couple of differences to F. The main one being I stuck
with the system from False where symbols don't evaluate to their
value. Instead you use ';' to get the value and '!' to execute it.
This means you need to use 'set' to set the value of a symbol:
[[1 =][][dup;!1 - fac;!*]cond;!] fac set
1000 fac;! .
...a very long number...
I use libgmp to get big numbers. The above factorial runs surprisingly
fast. Given that 'cond' is not a primitive and is implemented in the
prelude this results in lots of queue pushing and popping.
The README at
http://github.com/doublec/cf/tree/master describes how
to build, run it, the various primitives, etc.
Chris.
--
http://www.bluishcoder.co.nz