It is easy to express and, or, and not in terms of if (with an assist from a local binding for or). I'd like to know if the reverse is true. My naïve first attempt:
(if test conseq altern) => (or (and test conseq) altern)
However, if test is non-#f and conseq is #f, the translation evaluates to altern, which is incorrect.
Is there a translation that evaluates to the correct value while maintaining the short-circuit nature of if?
Sounds like you have a good explanation why if is doing a little more than and and or. But if you could cheat and add a lambda to delay the actual result:
(define-syntax-rule (if c t e) ((or (and c (lambda () t)) (lambda () e))))
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