set multiple symbols from list values at once

Q&A's, tips, howto's

set multiple symbols from list values at once

Postby vetelko » Sat Feb 11, 2017 3:22 pm

Hi guys,

is it possible to achieve something like this in newLISP?
Code: Select all
(assign name city age '("john", "new york", 22))
newLISP v.10.7.4 64-bit on OpenBSD IPv4/6 UTF-8 libffi
vetelko
 
Posts: 21
Joined: Thu Oct 13, 2016 4:47 pm

Re: set multiple symbols from list values at once

Postby jopython » Sat Feb 11, 2017 11:07 pm

You can't. unless you want to use title case.

Code: Select all
: (bind (unify '(Name City Age) '("john" "new york" 22)))
22
: Name
john
: City
new york
: Age
22
jopython
 
Posts: 123
Joined: Tue Sep 14, 2010 3:08 pm

Re: set multiple symbols from list values at once

Postby Lutz » Sat Feb 11, 2017 11:34 pm

use map and set
Code: Select all
> (map set '(name city age) '("john" "new york" 22))
("john" "new york" 22)

> name
"john"
> city
"new york"
> age
22
>
Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California


Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 1 guest