closures - What is the equivalent of Let Over Lambda in Scala? -
i trying adapt "land of lisp" scala , got stuck elegant way lisp can support memoization using classic let on lambda pattern. here example counter in lisp:
(let ((count 0)) (defun add-one () (incf count)))
how in scala. came with
val addone = { var count = 0 () => { count = count + 1; count } }
which don't find elegant. better proposals?
Comments
Post a Comment