In article <····················@hume.cs.orst.edu> ······@hume.cs.orst.edu (Peter Dudey) writes:
>CLtL2 (p. 399) says remove and it's relatives are non-destructive. Is
>this proper behavior, then?
>
>> (setq foo '(a b c d))
>(A B C D)
>> (setq bar (remove 'a foo))
>(B C D)
>> (delete 'd bar)
>(B C)
>> foo
>(A B C)
>>
There's an explanation on p. 400 that conflicts with the statement on p.399
to which you referred: "The result of remove may share with the
argument sequence; a list result may share a tail with an input list..."
So, it behooves the programmer to be aware of these "features" of the language
and write code accordingly.
In other words, be *very* careful when using destructive operations.
--
-- Pete Grant | Andrulis Research Corp is
Andrulis Research Corporation | on a contract with the US
·····@pentagon-gw.army.mil | Army AI Center, The Pentagon
(703) 271-7980 |
: In article <····················@hume.cs.orst.edu> ······@hume.cs.orst.edu (Peter Dudey) writes:
: >CLtL2 (p. 399) says remove and it's relatives are non-destructive. Is
: >this proper behavior, then?
: >
: >> (setq foo '(a b c d))
: >(A B C D)
: >> (setq bar (remove 'a foo))
: >(B C D)
: >> (delete 'd bar)
: >(B C)
: >> foo
: >(A B C)
: >>
Well, according to Franz, the delete function is destructive while
remove is non-destructive, so if you use (remove 'd bar) instead
of (delete 'd bar) you get
>foo
(A B C D)
I see no problem here.
--
TTFN, A^3 ···································@scs.leeds.ac.uk********
*******************************Temp*snail*9 Valkyrie Road, Wallasey**
**"If you're not here to kick *******mail*Wirral L45 4RG*************
**ass, get out." - jms **********Temp*Tel*UK-051-638-9714************