How to extract values from symbols in a list?

Q&A's, tips, howto's
Locked
jopython
Posts: 123
Joined: Tue Sep 14, 2010 3:08 pm

How to extract values from symbols in a list?

Post 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)


jopython
Posts: 123
Joined: Tue Sep 14, 2010 3:08 pm

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

Post by jopython »

never mind:

I figured it is
(map eval mems)

rickyboy
Posts: 607
Joined: Fri Apr 08, 2005 7:13 pm
Location: Front Royal, Virginia

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

Post 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))
(λx. x x) (λx. x x)

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

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

Post by Lutz »

and this too: (eval (cons list mems)) w/o the quote ;)

jopython
Posts: 123
Joined: Tue Sep 14, 2010 3:08 pm

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

Post by jopython »

Thank you for the quick responses. Love you people.

Locked