What's so special about IF?
From: David Steuber (david_at_david-steuber.com)
Date: 12/21/04
- Next message: Geoffrey Summerhayes: "Re: Yet another FORMAT questionn, ~@? this time"
- Previous message: Geoffrey Summerhayes: "Re: Yet another FORMAT questionn, ~@? this time"
- Next in thread: Artie Gold: "Re: What's so special about IF?"
- Reply: Artie Gold: "Re: What's so special about IF?"
- Reply: Adam Warner: "Re: What's so special about IF?"
- Reply: Clive Tong: "Re: What's so special about IF?"
- Reply: Jeff M.: "Re: What's so special about IF?"
- Reply: lin8080: "Re: What's so special about IF?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 21 Dec 2004 00:04:23 -0500
The CLHS states that IF is a Special Operator. But what if there was
no IF? Don't ask my why I was thinking about this. Just for fun, I
decided to see if I could use the Macros AND and OR along with the
function NOT to see if I could emulate IF:
(defmacro my-if (test then &optional (else nil))
(let ((b (gensym)))
`(let ((,b ,test))
(or (and ,b ,then)
(and (not ,b) ,else)))))
Some of the inspiration came from a digital logic course I once took
which reduced everything in a computer to several fundamental gates.
I know it's trivial, but I find this a rather eloquent answer to what
makes Lisp special.
-- An ideal world is left as an excercise to the reader. --- Paul Graham, On Lisp 8.1
- Next message: Geoffrey Summerhayes: "Re: Yet another FORMAT questionn, ~@? this time"
- Previous message: Geoffrey Summerhayes: "Re: Yet another FORMAT questionn, ~@? this time"
- Next in thread: Artie Gold: "Re: What's so special about IF?"
- Reply: Artie Gold: "Re: What's so special about IF?"
- Reply: Adam Warner: "Re: What's so special about IF?"
- Reply: Clive Tong: "Re: What's so special about IF?"
- Reply: Jeff M.: "Re: What's so special about IF?"
- Reply: lin8080: "Re: What's so special about IF?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|