[Openmcl-devel] surprising: (subst nil x ...) vs. (substitute x nil ...)

Brian Mastenbrook bmastenb at cs.indiana.edu
Wed Apr 6 16:50:03 PDT 2005


On Apr 6, 2005, at 6:37 PM, Alan Ruttenberg wrote:

> Is this correct?
>
> (substitute 1 nil '(nil 2))
> (1 2)
>
> (subst 1 nil '(nil 2))
> (1 2 . 1)
>
> -Alan

Yup. Remember that '(nil 2) is also '(nil 2 . nil). substitute operates 
on lists; subst operates on trees of cons cells. So in this case it's 
finding a cons cell (2 . nil) whose cdr is what you asked to replace 
with 1.
--
Brian Mastenbrook
brian at mastenbrook.net
http://www.iscblog.info/




More information about the Openmcl-devel mailing list