Q&A's, tips, howto's
-
cormullion
- Posts: 2038
- Joined: Tue Nov 29, 2005 8:28 pm
- Location: latiitude 50N longitude 3W
-
Contact:
Post
by cormullion »
Given two lists, what's the easiest way to splice them together.
From this:
Code: Select all
(set 'a '(fred jim bob))
(set 'b '(1 2 3))
to this
... coming back to some newLISP coding after a few weeks away and I think I'm rusty...
-
m i c h a e l
- Posts: 394
- Joined: Wed Apr 26, 2006 3:37 am
- Location: Oregon, USA
-
Contact:
Post
by m i c h a e l »
This does the trick:
I’m sure there’s an even better way, though.
m i c h a e l
-
cormullion
- Posts: 2038
- Joined: Tue Nov 29, 2005 8:28 pm
- Location: latiitude 50N longitude 3W
-
Contact:
Post
by cormullion »
Thanks! I've forgotten more than I thought! :)
-
Sammo
- Posts: 180
- Joined: Sat Dec 06, 2003 6:11 pm
- Location: Loveland, Colorado USA
Post
by Sammo »
Another solution:
Code: Select all
(transpose (list a b))
>((fred 1) (jim 2) (bob 3))
and applying transpose again has the effect of undoing:
Code: Select all
(transpose (transpose (list a b)))
>((fred jim bob) (1 2 3))
-
cormullion
- Posts: 2038
- Joined: Tue Nov 29, 2005 8:28 pm
- Location: latiitude 50N longitude 3W
-
Contact:
Post
by cormullion »
like it!
-
Tim Johnson
- Posts: 253
- Joined: Thu Oct 07, 2004 7:21 pm
- Location: Palmer Alaska USA
Post
by Tim Johnson »
I use this function
Code: Select all
(define (merge)(transpose (args)))
Lutz is a man of few words ...
Programmer since 1987. Unix environment.