Why is it not possible to simulate "if-then-else" construct as a function in interpreter that supports function application? Is "let" function in Scheme similar to "if-then-else"?
An if statement in Scheme looks like:
(if <predicate> <consequent> <alternate>)
and is defined such that the <consequent> is evaluated only when the <predicate> is not false and such that the <alternate> is evaluated only when the <predicate> is false. So you can see that something like
(if #t (display "okay") (shut-down-the-nsa))
would never actually shut down the NSA.
But, if if is a function, like:
(<operator> <operand> …)
then each <operand> is always evaluated. In the context of an if statement, that means both the <consequent> and <alternate> would be evaluated - not much of an if then.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With