Arc Forumnew | comments | leaders | submitlogin
2 points by vrk 6155 days ago | link | parent

This is exactly what Scheme's letrec does. Try it in mzscheme, which you will have installed if you're playing with arc1:

  (letrec ((foo (lambda (x) (bar x))) 
           (bar (lambda (x) (+ 1 x)))) 
    (foo 5))
(As an aside, it's beginning to be obvious how many redundant parentheses Scheme and most other Lisps have.)


1 point by cchooper 6155 days ago | link

letrec won't work for non-function definitions, for example:

  (letrec ((x 5)
           (y x))
    y)
For this, you need let-star (not sure how to write that in markdown), but let-star doesn't give you forward reference, so nothing is quite right.

-----

5 points by shiro 6155 days ago | link

Oh, if you want that, check out letrec*.

http://www.r6rs.org/final/html/r6rs/r6rs-Z-H-14.html#node_id...

-----

1 point by cchooper 6155 days ago | link

That's it, perfectly!

-----

4 points by pg 6154 days ago | link

You can just write let* so long as there is a space after the asterisk.

-----

1 point by cchooper 6154 days ago | link

Ah, the problem was I had a comma after it. Thanks.

-----

1 point by andreyf 5843 days ago | link

let*, huh?

-----