Another sample for set-ref doc

Q&A's, tips, howto's
Locked
HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Another sample for set-ref doc

Post by HPW »

When I want to do the same as with the longtime depreciated 'replace-assoc' it would be this:

Code: Select all

> (set 'data '(fruits (apples 123 44) (oranges 1 5 3)))
(fruits (apples 123 44) (oranges 1 5 3))
> (set-ref (assoc 'apples data) data '(Apples 456 55))
(fruits (Apples 456 55) (oranges 1 5 3))
Makes for me more sense as a real world example.

Regards
Hans-Peter

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: Another sample for set-ref doc

Post by Lutz »

but an example better handled with setf as explained in the previous thread

Code: Select all

(setf (assoc 'apples data) '(Apples 456 55))

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Re: Another sample for set-ref doc

Post by HPW »

Very nice.

Put both in the doc. ;-)
Hans-Peter

Locked