Q&A's, tips, howto's
-
cameyo
- Posts: 183
- Joined: Sun Mar 27, 2011 3:07 pm
- Location: Italy
-
Contact:
Post
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
-
Lutz
- Posts: 5289
- Joined: Thu Sep 26, 2002 4:45 pm
- Location: Pasadena, California
-
Contact:
Post
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.
-
cameyo
- Posts: 183
- Joined: Sun Mar 27, 2011 3:07 pm
- Location: Italy
-
Contact:
Post
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
-
rickyboy
- Posts: 607
- Joined: Fri Apr 08, 2005 7:13 pm
- Location: Front Royal, Virginia
Post
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))))
(λx. x x) (λx. x x)
-
cameyo
- Posts: 183
- Joined: Sun Mar 27, 2011 3:07 pm
- Location: Italy
-
Contact:
Post
by cameyo »
Thanks.
A big help for me.
cameyo