Evaluating symbols in nested lists

Notices and updates
Locked
Tim Johnson
Posts: 253
Joined: Thu Oct 07, 2004 7:21 pm
Location: Palmer Alaska USA

Evaluating symbols in nested lists

Post 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

Tim Johnson
Posts: 253
Joined: Thu Oct 07, 2004 7:21 pm
Location: Palmer Alaska USA

Post 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

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

Post by Lutz »

just do:

Code: Select all

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

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

Tim Johnson
Posts: 253
Joined: Thu Oct 07, 2004 7:21 pm
Location: Palmer Alaska USA

Post by Tim Johnson »

Understood.
Thanks, Lutz

Locked