[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: subst-if-not and nsubst-if-not, programming folk-lore
- To: Common-Lisp@SU-AI.ARPA
- Subject: Re: subst-if-not and nsubst-if-not, programming folk-lore
- From: Masinter.pa@Xerox.COM
- Date: Mon, 07 Jul 1986 14:15:00 -0000
- In-reply-to: Guy Steele <gls@Think.COM>'s message of Mon, 7 Jul 86 10:30 EDT
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. :-).