Page 1 of 1

Apply error message

Posted: Sat Nov 17, 2018 3:03 pm
by cameyo
The following expression give me an error:

Code: Select all

(apply map list '((a 1) (b 2) (c 3)))
ERR: list expected in function apply : list@4095B0
Instead, I wish the output was:
((a b c) (1 2 3))
Can someone help me?
Thanks

cameyo

Re: Apply error message

Posted: Sat Nov 17, 2018 6:00 pm
by Lutz
Use transpose:

Code: Select all

> (transpose '((a 1) (b 2) (c 3)))
((a b c) (1 2 3))
> 
A hint will be added to the description of list in the manual.

Re: Apply error message

Posted: Sat Nov 17, 2018 8:05 pm
by cameyo
"transpose" works like i want :-)
But is the expression wrong logically or syntactically?
Why "apply" does not receive a list?
Thanks again

cameyo

Re: Apply error message

Posted: Sat Nov 17, 2018 11:58 pm
by rickyboy
cameyo wrote:But is the expression wrong logically or syntactically?
Why "apply" does not receive a list?
This is what you had been looking for originally.

Code: Select all

(apply map (cons list '((a 1) (b 2) (c 3))))

Re: Apply error message

Posted: Sun Nov 18, 2018 10:58 am
by cameyo
Thanks.
A big help for me.

cameyo