On Tue, Dec 28, 2021 at 02:58:56AM -0500, Thien-Thi Nguyen wrote: > > () > () Tue, 28 Dec 2021 08:19:04 +0100 > > I /think/ the ellipsis is at a wrong place there [...] > Haha, i know exactly how you feel. %-) > Ah, right! The ellipses are a tail that need to follow a head. No, the ellipses tell the matcher that the symbol to its left acutally stands for "zero or more of this". Consequently, you have to somehow [1] use those ellipses on the right hand side (aka template) whenever you use them on the left hand side (aka pattern) and vice versa. > I guess i was confused by the documentation's use of ellipses in > the conventional sense rather than the literal sense: I think of the ellipses as a kind of funny Kleene star. Not really at home in any world: in the regular world, because it isn't a star, in the Scheme world, because it is postfix. So, to come back on your original example, (@ . ,attrs) ... would match either empty (remember: zero or more) or (@ (foo 1) (bar 2)) or (@ (meep 1)) (@ "this ain't what we expected)) ... so zero or more of (@ . stuff) where stuff stands for any S-expression (note that it's sloppy: it will match things which aren't lists of well-formed attribute lists [2]). It won't match (@ (foo 1)) (@ (bar 2)) ("rumpelstilzchen") for example. > Anyway, thanks to your help, i've managed to cobble together the > following code, attached here for the benefit of future self: [...] Thanks. And thanks for the code :) > Maybe it's idiomatic. Feedback on how to improve it welcome! For the idiomatic part, I'll have to defer to those with more chevrons ;-) Cheers [1] Yes, some handwaving here. [2] which isn't what you want to match, anyway. You want to match things with one attribute list in them. Cheers -- t