3 ms·
It's used to implement a generalization of assignment. If you have a special form that can tell you where something is stored, you can make macros to set it. E.
by pg 7y ago
It's used to implement a generalization of assignment. If you have a special form that can tell you where something is stored, you can make macros to set it. E.g.
> (set x '(a b c))
(a b c)
> (set (2 x) 'z)
z
> x
(a z c)
which you can do in Common Lisp, and
> (set ((if (coin) 1 3) x) 'y)
y
> x
(y z c)
which you can't.
- soulofmischief 7y agoThanks for sharing, Paul. Still knee-deep in the source. Gonna steal some of this. What made you settle on (coin), is that a LISP trope? I flopped back and forth between naming it (coin) and (flip) in my own LISP before finally settling on (flip). I'd honestly like to divorce the name entirely from its physical counterpart.
- defen 7y ago> I'd honestly like to divorce the name entirely from its physical counterpart. How about (bit) or (randbit)
- soulofmischief 7y ago(randbit) isn't bad. My implementation also takes a float 0 <= x <= 1 to determine the probability of the outcome, so (bit) would probably be too ambiguous. I do like the brevity of a 4-letter function, though. A lot of my lisp coding is genetic and probabilistic so it gets used a lot.
- e12e 7y agodice?
- pg 7y agoI originally did call it flip, but then I took that name for the current flip: (def flip (f) (fn args (apply f (rev args))))
- sillysaurusx 7y agoI am diliriously happy to see you here commenting about lisp. I grew up with your writing and your work and... I don’t know, I just wanted to express excitement. Thanks for the new dialect!
- akkartik 7y agoWould be the result of (where (cadr x)) still be ((a b c) d)? Is where basically tracking the most recent traversal?