Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Using let in Scheme

Name: Anonymous 2013-01-17 2:23

I remember a post a while back where the author said that it's better to avoid using binding constructs like let in languages like Scheme. I was wondering how you'd rewrite something like this:
(let ((s (find (lambda (a) (char=? x (first a))) *translation-list*)))
 (if s (second s) x))

Name: Anonymous 2013-01-20 3:02

>>6

Here's a start if you want to implement letrec. You can express recursion without recursion by passing the function as a parameter to itself. I think think of a way to do it in a macro that doesn't require recursive substitution of variable names though.


(define fact-helper (lambda (f n)
  (if (= n 0)
    1
    (* n (f f (- n 1))))))

(define factorial (lambda (n) (fact-helper fact-helper n)))

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List