Fexl is an interpreter for a functional programming language in which everything is a function, including data itself. The interpreter is written in standard C and compiled with strictness and optimization.
This is version b13 published Wed 2011-08-31. See the history of release notes for more information.
You can browse the source code on Github.
In addition to that master branch, there's also a new branch under development. That's a technically superior rewrite of all the code, though incomplete and still in progress.
First, click here to download the code as a compressed archive.
Save that file in your Downloads directory or wherever. Then unpack it and go into the source code directory:
cd ~/Downloads tar -xzf b13.tar.gz cd b13/src
There you will see a README file with background information and installation instructions. Installation is simple. To build the fexl program and put it in /usr/bin, do this:
./build install
To build the fexl program locally, only in the ../bin directory, so you can test it without a final installation, do this:
./build
After building it either way, you can run this test program if you like:
cd ../test ./try.fxl
The grammar (implemented in parse.c) is:
exp => empty exp => term exp exp => ; exp exp => \ sym def exp term => sym term => ( exp ) def => empty def => is term is => = is => ==
The interpreter is based entirely on combinatorics. All symbol references are abstracted out, leaving only basic combinators such as S, C, L, R, I, and Y as control structures.
As an example, here is the function which appends two lists:
\append == (\x\y x y \h\t item h; append t y)
Note that for recursive definitions, you must use "==" instead of "=". This explicit notation has definite advantages. In particular, it allows you to write code that looks "procedural", with incremental calculations that look like destructive assignment but really aren't:
\x=3.0 \y=4.0 \x=(add x x) \y=(mul y; add 1.0 x) ...
The '=' form also has the benefit of forcing eager evaluation of the symbol's definition.
Also note the use of the ";" operator, also known as "right-pivot", to avoid parentheses on expressions nested toward the right. Without the ";", the function would be:
\append == (\x\y x y \h\t item h (append t y))
It doesn't make a lot of difference there, but it comes in very handy with highly sequential functions such as:
print "The value of x is "; print x; nl; print "The value of y is "; print y; nl; stop
Fexl currently has built-in functions for manipulating long, double, and string values.
This program is unrelated to Fexl. The clump program lets you write C code and simply type "clump" to compile and link it. No makefiles are necessary. It automatically detects and checks dependencies.
Download or browse the code at Github.
Download the code directly from this site as a compressed archive.