Questions tagged [letrec]

A recursive let construct in e.g. Scheme whereas the "right hand side" can refer to the name being defined. By naming the implicitly defined procedure, lets us reuse it, i.e. call it recursively.

A recursive let construct in Scheme and other functional languages whereas the "right hand side" can refer to the name being defined. By naming the implicitly defined procedure, lets us reuse it, i.e. call it recursively.

38 questions
0
votes
2 answers

Is letrec only meant for defining procedures?

Is Scheme's letrec only meant for defining procedures, especially recursive ones? I am asking because it appears to be possible to bind non-procedures using letrec. For example, (letrec ((x 1) (y 2)) (+ x y)). If Scheme's letrec is only meant for…
Flux
  • 9,805
  • 5
  • 46
  • 92
0
votes
3 answers

Why does let not allow mutually recursive definitions, whereas letrec can?

I suspect that I fundamentally misunderstand Scheme's evaluation rules. What is it about the way that let and letrec are coded and evaluated that makes letrec able to accept mutually recursive definitions whereas let cannot? Appeals to their basic…
J. Mini
  • 1,868
  • 1
  • 9
  • 38
0
votes
1 answer

Can letrec be the same as letrec*?

If I have implemented letrec* in my Scheme interpreter, can I simply implement letrec by making it the same as letrec*? Is this allowed by the Scheme standards?
Flux
  • 9,805
  • 5
  • 46
  • 92
0
votes
0 answers

Generalised letrec semantics for mutual recursion

I'm new to system types and I was wondering how mutual recursion is defined through generalized let rec x1=e1 ,....,xn=en in e .What has to be added in the "simple" letrec's semantics and evaluation rules and how is its syntactic sugar (using fix )…
0
votes
2 answers

Understanding recurive let expression in lambda calculus with Haskell, OCaml and nix language

I'm trying to understand how recursive set operate internally by comparing similar feature in another functional programming languages and concepts. I can find it in wiki. In that, I need to know Y combinator, fixed point. I can get it briefly in…
varvir
  • 65
  • 1
  • 8
0
votes
2 answers

how to pattern match 'letrec'

I am trying to pattern match calls to letrec using match-lambda. It seems to me that this pattern: (match-lambda (`(letrec ((, ,) . (, ,)) , . ,) `()) should match calls of the form: (letrec ((
Schemer
  • 1,635
  • 4
  • 19
  • 39
0
votes
2 answers

Ocaml, implement freevars letrec using sets

I'm trying to implement letrec using mathematical lambda notation for the function, but I'm having difficulty. My assignment says that let can be defined as p(e1) U (p(e2) - {x}) and that letrec can be defined as (p(e1) - {f x}) U (p(e2) - {f})…
0
votes
1 answer

understanding tail recursion 2

Originally I posted one question "understanding a tail-recursive vector->list answer" and this is additional questions. my general understanding in scheme is really vague. so I have now several more questions: ;;;;;; original code…
user1915570
  • 386
  • 2
  • 7
  • 27
1 2
3