Overall I find it pretty good, but a bit simple provided you already know something related to the lisp world.
After finishing it, I tried a couple of tricks in lisp, and was surprised how easy it was to come with working codes of a memoized function. Once you have a memoized function, why not convert it to a memoizer function?
Here it is. (If you're reading it on google reader you won't be able to see it, better read blogposts from the original site)
(setf memofib (memoizer #'fib))
(funcall memofib 10)
And you have now a faster fib than before.
Question: how should I change it to make a generic memoizer that memoizes not only unary functions.
In perl I'd have to just pass @_, I suppose changing arg to '&rest arg' and change funcall to apply would do the trick... I have to try it. Later.
More readings: Scheme R5RS.
I read the part I hadn't read before. I have to say even the scheme spec is minimalist, well written, and didactic. Following the language philosophy even at docs level. :)
And a bit more: A paper on Scheme macros. I think I get them, but I don't see much use for them. I suppose I'm still an average blub programmer.
No hay comentarios:
Publicar un comentario