Page 1 of 1

Another sample for set-ref doc

Posted: Thu Aug 01, 2013 12:56 pm
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

Re: Another sample for set-ref doc

Posted: Thu Aug 01, 2013 1:53 pm
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))

Re: Another sample for set-ref doc

Posted: Thu Aug 01, 2013 3:46 pm
by HPW
Very nice.

Put both in the doc. ;-)