On 12/17/2010 06:34 AM, Jim Wise wrote:
> * a proper or improper list of N subpatterns with the literal `...`
symbol
> occurring once or more in any position except either the first position
> of any list, or the last position of an improper list.
>
> examples:
> {{{
> (a ... b c)
> (a (b c) ... d)
> (a b ... . d)
> }}}
>
> in this case, the pattern list is matched as in the above proper or
> improper list cases, except that the subpattern before the `...` symbol
> can match zero or more instances of the pattern preceding the `...`
> symbol. Variables bound by a subpattern preceding a `...` are bound to
> a (possibly empty) list of all values matched by the pattern as if by a
> `map` of the `match` operator for that subpattern over each individual
> value matched.
Note this is inconsistent with syntax-rules patterns, which requires ...
also in each *use* of the match. I.e. the variables bound by a
subpattern preceding
a '...' are matched to some kind of *handle* to a list, not an actual list.
(match '((a . 1) (b. 2) (c . 3))
(((x . y) ...) (cons (list x ...) (list y ...))))
==> ((a b c) . (1 2 3))
I think requiring ... in expressions is a feature, not a problem.
For example, it enables:
(match '((a . 1) (b. 2) (c . 3))
(((x . y) ...) (list (y . x) ...)))
==> ((1 . a) (2 . b) (3 . c))
I'm working on a sequence/iteration/looping framework that
makes use of this idea. Coming soon ...
--
--Per Bothner
[email protected] http://per.bothner.com/
_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss