vlion: cut of the flammarion woodcut, colored (Default)
2010-08-12 12:14 am
Entry tags:

(no subject)

Jotting down for later polishing.


Given a list that denotes a computation.
(setq myawesomelist '(+ X (- (1+ X) X)))

Then, this macro will take that list and generate an 'anonymous' function that can be bound and saved.

;;Turns a tree into a lambda
(defmacro tree-to-lambda(tree)
  "Takes a tree and turns it into the lambda of its function"
  (eval ``(lambda (X) 
     ,,tree)))


Then
 (funcall (tree-to-lambda myawesomelist) 4)
will compute the function denoted by myawesome list on parameter=4.

Gnu common lisp was used.

That macro took some 5 hours to work out.

I spent a previous evening diddling with it in April or so, I think. Prior to that, I built the list-generating framework in... 2005? 2006? It was hideously crufty.

I do remember staring at it this spring and thinking I was smarter then. It depressed me enough I start poking at it again.

I have a small library of fuzzy comparisons and tree adjustment routines I had built to try to mutate/combine lists. The goal here is to evolve a program that will - after some work - compute a specified input function.

Note to self - figure out multi-parameter functions... later.