You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't believe this was previously possible, so I've implemented the call-self operator, which provides a clear and straightforward method to recurse within a lambda.
The above code can now be written as:
(define (multo ex) (lambda (n) (if (=0 n) 1 (* ex (call-self (- n 1))))))
Also, I've just published this as part of version 0.11.0 on crates.io.
In other lisps, this would be handled by creating a letrec binding to a lambda which calls on its own binding. No real need for the ability to specifically have a way to refer to self (but it can be done, if you are sufficiently inclined, given the general malleability of the family of lisps).
I'm trying to create a function that returns a function that calls itself. I tried this:
But it doesn't work because the lambda can't refer to
f
inside the definition. How do I achieve this?The text was updated successfully, but these errors were encountered: