Page 1 of 1

set multiple symbols from list values at once

Posted: Sat Feb 11, 2017 3:22 pm
by vetelko
Hi guys,

is it possible to achieve something like this in newLISP?

Code: Select all

(assign name city age '("john", "new york", 22))

Re: set multiple symbols from list values at once

Posted: Sat Feb 11, 2017 11:07 pm
by jopython
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

Re: set multiple symbols from list values at once

Posted: Sat Feb 11, 2017 11:34 pm
by Lutz
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
>