Scheme: When to use let, let*, and letrec? -
this question has answer here:
what difference between let, let*, , letrec?
please give thorough explanations , examples.
your best bet read official r5rs descriptions of let, let*, , letrec.
in short, however:
(let ((x 2)) (let ((x 3) (y x)) y) => 2 (let ((x 2)) (let* ((x 3) (y x)) y) => 3
so difference between let , let* let evaluate bindings respect level above (so doesn't matter order they're listed in) while let* sequentially. (let* ((x a) (b y))) equivalent (let ((x a)) (let ((b y))).
letrec, on other hand, allows bind recursive values. might write recursive function want within function scope , bind name using letrec.
Comments
Post a Comment