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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -