[plt-scheme] Another pattern puzzle
At Thu, 15 Nov 2007 13:41:11 +0100, Jens Axel Soegaard wrote:
> An identifier matches a list pattern:
>
> > (syntax-case #'x ()
> [(a ... . more) 'huh?]
> [_ 'ok])
>
> huh?
It's not really a "list" pattern, though; it matches N chained cons
cells ending with something that matches `more', and `more' isn't
required to be a list.
So, #'x matches a chain of 0 cons cells ending with a match to `more'.
A related example:
> (syntax-case #'(1 . 2) ()
[(a ... . more) (syntax->datum #'more)])
2
> (syntax-case #'(1 1 1 1 . 2) ()
[(a ... . more) (syntax->datum #'more)])
2
> (syntax-case #'2 ()
[(a ... . more) (syntax->datum #'more)])
2
Matthew