Re: newbie question
- From: Frode Vatvedt Fjeld <frodef@xxxxxxxxx>
- Date: 31 Dec 2005 21:37:27 +0100
"dvlfrnd" <iresjen@xxxxxxxxx> writes:
> say there's a list of even length
> (a b c d e f ......)
>
> how do i turn this into
> ((a b) (c d) (e f)....)
The mapping idiom doesn't work so well here, since that's all about
transforming each element individually, whereas here you process
elements two by two (or the list as such in steps of two).
I think this is the most natural solution in Common Lisp:
(loop for (x y) on list by #'cddr collect (list x y))
--
Frode Vatvedt Fjeld
.
- References:
- newbie question
- From: dvlfrnd
- newbie question
- Prev by Date: Re: newbie question
- Next by Date: Re: newbie question
- Previous by thread: Re: newbie question
- Next by thread: Re: newbie question
- Index(es):