[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

subst-if-not and nsubst-if-not, programming folk-lore



    Date: Sun, 29 Jun 86 19:42 EDT
    From: David C. Plummer <DCP@QUABBIN.SCRC.Symbolics.COM>
    ...
    Now, when one tries subst-if-not, one gets a small surprise until one
    thinks about it a bit:

	(let* ((item-list '(numbers (1.0 2 5/3) symbols (foo bar)))
	       (new (subst-if-not '3.1415 #'numberp item-list)))
	  (values new item-list))
	=> 3.1415
	   (NUMBERS (1.0 2 5/3) SYMBOLS (FOO BAR))

How about
    (let* ((item-list '(numbers (1.0 2 5/3) symbols (foo bar)))
	   (new (subst-if-not '3.1415
			      #'(lambda (x) (or (numberp x) (listp x)))
			      item-list)))
      (values new item-list))
?

[I tried to test this, but there appears to be a trivial bug in the
Symbolics 3600 release 6.1 implementation of SUBST-IF-NOT.]

    What the person probably wanted is to replace the non-null atomic
    leafs.  I'm not sure what to think.  One thing I'm thinking is that
    (n)subst-if-not is too counter-intuitive to be worth having in the
    language, even for completeness.  At the very list, I think the
    book/manual should carefully discuss this issue to people don't get
    confused for years.

At the very LIST, you say?
--Guy