fun4j - functional programming for the JVM

The Lisp Read Eval Print Loop

The most simple way to interact with a Lisp system is through an interactive
Read-Eval-Print Loop. Fun4J also comes with such a "REPL".

To start up the fun4j REPL just
call java -jar fun4j.jar.
If you are working in an IDE you could as well start up the class org.fun4j.Repl directly.

After starting up you are prompted with the follwoing welcom message:

Welcome to fun4j [1.0.x]
input:

You can enter any lisp expression at the input prompt. See the next snippet for an example:

input: (+ 3 4)
elapsed time in msecs:0
value1: 7

The result of the computation is printed after a value<n>: label.
The result of the computation is also bound to a global variable value<n>.
So you can reuse the results of previous computations in new lisp expressions. See the following snippet for a simple example:

A lambda term (lambda (m n) (* m n)) is entered.
The result of this expression is a compiled function.
Each compiled functions maintains a string representation of its underlying AST which can be used
for a human readable representation. This representation is printed out: value1: Example1(args) => args[0]*args[1][]

In the next line this function object is applied to the argument 7.
As the original function has two arguments this function application is only a partial one, as one argument remains unbound.
Thus the result of this application is a closure of the original function and the single argument 7:
value2: Example1(args) => args[0]*args[1][7]

This closure is again a function, now one with only one unbound variable. Thus a call to the single argument 6 (value2 6) results
in a multiplication of the bound arguments 6 and 7.

Useful functions

Enter (tracing true) to enable tracing of function calls.
(tracing false) deactivates tracing.
Here is a short example of tracing the factorial function:

By default fun4j uses BigIntegers for all int arithmetic operations.
If you want to change this you can call (bigints false).
It is important to note that this flag affects the Lisp parser and the Lisp compiler.
If you change this flag in the middle of a session the Parser will generate Integer object while the
compiled code still expects BigIntegers and vice versa.
To avoid problems with this flag better use it before doing any compilations.
Or reload all definitions like in the following example session: