tuturto / apocrita

A very simple lisp, implemented in hy
MIT License
4 stars 0 forks source link

memoization #6

Open tuturto opened 8 years ago

tuturto commented 8 years ago

Functions could memoize (automatically?, based on keyword?), so successive calls with same parameters wouldn't have to be computed, but could be returned from cache instead.

tuturto commented 8 years ago
=> (define n!
...  (memoize
...    (lambda (n)
...      (cond ((= n 0) 1)
...            (#t (* (n! (- n 1)) n))))))
<closure: n>
=> (n! 0)
1
=> (n! 4)
24

Pitäisikö memoisaatio näkyä tyypistä?

<closure: n>
vs
<closure (memoized): n>