Write Yourself a Scheme in 48 Hours: 11. Towards a Standard Library is a very interesting read. I found this by off chance in a Google search. I don’t really care for the Haskell part, but what did intrigue me, was the simplicity they described fold and unfold and how they apply it.
Off course the challenge was to actually test this code on IronLisp. At first I was rewriting alot to IronLisp dialect, this got tedious and error prone. I decided to use macro’s for what they intended for. Anyways 2 macro’s was sufficient for the bulk. And here they are:
(defmacro lambda (&rest body) `(fn ,@body)) (defmacro define (nargs &rest body) `(defun ,(car ,nargs) ,(cdr ,nargs) ,@body))
As said, the aim was to test it, and beyond my expectations, it passed flying colors first time (except for a few syntax issues, like ‘new’ and clashing with existing functions).
I will be doing a checkin tonite. Some other things might still be broken, but you will get a nice dialog showing my acknowledgment of the issue :)