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

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



Sounds like people want the equivalent of Interlisp's SUBST:

(SUBST NEW OLD EXPR)  	[Function]

Returns the result of substituting NEW for all occurrences of OLD in the
expression EXPR.  Substitution occurs whenever OLD is EQUAL to CAR of
some subexpression of EXPR, or when OLD is atomic and EQ to a non-NIL
CDR of some subexpression of EXPR.  For example:

(SUBST 'A 'B '(C B (X . B)))  =>  (C A (X . A))
(SUBST 'A '(B C) '((B C) D B C))
          =>  (A D B C)  not  (A D . A)

SUBST returns a copy of EXPR with the appropriate changes.  Furthermore,
if NEW is a list, it is copied at each substitution.

If the standard called it "IL:SUBST" then we wouldn't have to do any
work. :-).