Page 1 of 1

How to extract values from symbols in a list?

Posted: Mon May 20, 2013 1:09 pm
by jopython
I have a list of symbols in a list named 'mems'
How do i extract the "values" of those symbols instead of the symbols themselves?

Code: Select all

: mems
(s1 s2 s3 s4 s5)

: s1
("hi")

: (map symbol? mems)
(true true true true true)


Re: How to extract values from symbols in a list?

Posted: Mon May 20, 2013 1:15 pm
by jopython
never mind:

I figured it is
(map eval mems)

Re: How to extract values from symbols in a list?

Posted: Mon May 20, 2013 2:58 pm
by rickyboy
That's great. I sometimes have to ask someone about a problem I'm stuck on, and then in the asking, I figure out myself what the problem is. I think that often the only thing we need is a sounding board. Excellent.

BTW, this too might work: (eval (cons 'list mems))

Re: How to extract values from symbols in a list?

Posted: Mon May 20, 2013 3:15 pm
by Lutz
and this too: (eval (cons list mems)) w/o the quote ;)

Re: How to extract values from symbols in a list?

Posted: Mon May 20, 2013 8:54 pm
by jopython
Thank you for the quick responses. Love you people.