3 ms·
>> kazinator The let special form is a syntactic sugar for IIFEs which has the advantage of highlighting local variables ; so the previous area2 function can b
by martyalain 6y ago
>> kazinator
The let special form is a syntactic sugar for IIFEs which has the advantage of highlighting local variables ; so the previous area2 function can be rewritten this way:
{def area3
{lambda {:a :b :c}
{let { {:a :a} // in fact, it's a hidden lambda
{:b :b} // we must redefine the outer lambda's arguments
{:c :c} // as kind of "manual" closure
{:s {/ {+ :a :b :c} 2}} // and add the new computed variable
} {sqrt {* :s {- :s :a} {- :s :b} {- :s :c}}} everything is known
}}}