Page 1 of 1

Evaluating symbols in nested lists

Posted: Mon Dec 24, 2007 1:13 am
by Tim Johnson
I have the following symbols and values:
> key
"test"
> res
(("test" "one"))
> val
"one"
> newval
"two"
;; And I want to change 'res to (("test" ("one" "two"))
;; but:

Code: Select all

(replace-assoc key res '(key (list val newval)))
;; gives me
(key (list val newval))
I understand that the symbols in '(key (list val newval))
aren't being evaluated, but don't
know which function to use to evaluate them.
Thanks
Tim

Posted: Mon Dec 24, 2007 1:51 am
by Tim Johnson
Never mind:
I was looking for this:

Code: Select all

(replace-assoc key res (expand '(key (val newval))
                                           'key 'val 'newval))
Doesn't common lisp use the comma operator to do the
same thing?
thanks
Tim

Posted: Mon Dec 24, 2007 2:22 am
by Lutz
just do:

Code: Select all

(replace-assoc key res (list key (list val newval)))

=> (("test" ("one" "two")))
Lutz

Posted: Mon Dec 24, 2007 3:05 am
by Tim Johnson
Understood.
Thanks, Lutz