Rob Warnock wrote:
> The problem with any such automatic sizing is LOOPs like this:
>
> (loop for (a b c . rest) on list by #'cdddr ...)
>
> or even this:
>
> (flet ((stepper (list)
> (case (car list)
> ((:one) (cddr list))
> ((:two) (cdddr list))
> ((:three) (cdddr list))
> (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)
Let's test that crap.
(setq mlist
'(:one 123 :two 234 453 :three 7 5 8 :special :other 99 22 :two 34 54))
(flet ((stepper (list)
(case (car list)
((:one) (cddr list))
((:two) (cdddr list))
((:three) (cdddr list))
(otherwise (cdr list)))))
(loop for (key a b c) on mlist by #'stepper
do (print (list key a b c))))
(:ONE 123 :TWO 234)
(:TWO 234 453 :THREE)
(:THREE 7 5 8)
(8 :SPECIAL :OTHER 99)
(:SPECIAL :OTHER 99 22)
(:OTHER 99 22 :TWO)
(99 22 :TWO 34)
(22 :TWO 34 54)
(:TWO 34 54 NIL)
(use srfi-1) ; break
(define (parse-list the-list)
(if (null? the-list)
'()
(receive (included excluded) (break keyword? (cdr the-list))
(cons (cons (car the-list) included) (parse-list excluded)))))
(parse-list
'(one: 123 two: 234 453 three: 7 5 8 special: other: 99 22 two: 34 54))
===>
((one: 123) (two: 234 453) (three: 7 5 8) (special:) (other: 99 22)
(two: 34 54))
--
[A]n unholy alliance of leftists, capitalists, and Zionist supremacists has
schemed to promote immigration and miscegenation with the deliberate aim of
breeding us out of existence in our own homelands.... [T]he real aim stays the
same: the biggest genocide in human history.... --- Nick Griffin
(
https://www.youtube.com/watch?v=K0hD7IffTJs)