Open tuturto opened 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>
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.