Writing S-expression inside Java codes
I recently created a library that evaluates java.lang.Objects as S-expressions (my summer homework;)). In other words, you can embed a LISP program inside Java code, but unlike fun4j you don't need to write your LISP code as a String. You can write it as a real Java program. That is,
Basic.eval(
progn(
assign($("i"), 0),
loop(
lt($("i"), 10),
print(format("@@@@@@@@ %s @@@@@@@@\n", $("i"))),
assign($("i"), add($("i"), 1))
)
)
);
where progn, assign, loop, lt, print, and so on are names of Java methods that return evaluatable objects (java.lang.Object[]'s) and Basic.eval is a function that does the 'evaluate' on given java.lang.Object.
This program produces the output below
@@@@@@@@ 0 @@@@@@@@
@@@@@@@@ 1 @@@@@@@@
@@@@@@@@ 2 @@@@@@@@
@@@@@@@@ 3 @@@@@@@@
@@@@@@@@ 4 @@@@@@@@
@@@@@@@@ 5 @@@@@@@@
@@@@@@@@ 6 @@@@@@@@
@@@@@@@@ 7 @@@@@@@@
@@@@@@@@ 8 @@@@@@@@
@@@@@@@@ 9 @@@@@@@@
It's not yet published in Maven's Central Repository, but will become available soon.
The source code is found here: https://github.com/dakusui/petronia/