newLISP Fan Club

Forum => newLISP newS => Topic started by: Tim Johnson on December 23, 2007, 05:13:36 PM

Title: Evaluating symbols in nested lists
Post by: Tim Johnson on December 23, 2007, 05:13:36 PM
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:
(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
Title:
Post by: Tim Johnson on December 23, 2007, 05:51:53 PM
Never mind:

I was looking for this:
(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
Title:
Post by: Lutz on December 23, 2007, 06:22:43 PM
just do:


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

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


Lutz
Title:
Post by: Tim Johnson on December 23, 2007, 07:05:35 PM
Understood.

Thanks, Lutz