Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

.re: Idiom for gathering pairs from a list?

12 views
Skip to first unread message

Robert L.

unread,
Jan 21, 2017, 1:42:45 PM1/21/17
to
Rob Warnock wrote:

> or even this:
>
> (flet ((stepper (list)
> (case (car list)
> ((:one) (cddr list))
> ((:two) (cdddr list))
> ((:three) (cdddr list))

Wrong. Try cddddr.

> (otherwise (cdr list)))))
> (loop for (key a b c) on list by #'stepper ...))
>
> which can parse lists like this:
>
> (:one 123 :two 234 453 :three 7 5 8 :special :other 99 22 :two 34 54)

Wrong. :other isn't handled correctly.

Ruby:

[:one,123,:two,234,453,:three,7,5,8,:special,:other,99,22,:two,34,54].
slice_before{|x| x.is_a? Symbol}.to_a

===>
[[:one, 123],
[:two, 234, 453],
[:three, 7, 5, 8],
[:special],
[:other, 99, 22],
[:two, 34, 54]]

In Forth?

--
For two years ... he was held in solitary confinement in the Toronto West
Detention Centre.... [A] court in Mannheim sentenced him to five years
imprisonment for the crime of "popular incitement" under Germany's notorious
"Holocaust denial" statute. www.revisionists.com/revisionists/zundel.html
0 new messages