<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Aug 6, 2014, at 1:47 PM, Alexander D. Knauth <<a href="mailto:alexander@knauth.org">alexander@knauth.org</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div><br></div><div><br></div><div>On Aug 6, 2014, at 1:10 PM, Kevin Forchione <<a href="mailto:lysseus@gmail.com">lysseus@gmail.com</a>> wrote:</div><div><br class="Apple-interchange-newline"><blockquote type="cite"><br>On Aug 5, 2014, at 2:21 PM, Jens Axel Søgaard <<a href="mailto:jensaxel@soegaard.net">jensaxel@soegaard.net</a>> wrote:<br><br><blockquote type="cite">Is this a step in the right direction?<br><br>(define-syntax (x stx)<br>(syntax-parse stx<br>  [(_ (y ... (z ...) w ...))<br>   #'(xf (yf y ... (zf z ...) w ...))]))<br><br>The pattern (z ...) ... will match a sequence of lists such as (4 5 6) (7 8)<br>but it won't match (4 5 6) 7 8 from your example.<br><br>/Jens Axel<br></blockquote><br>Closer. It doesn’t match something like ‘( 1 2 3 (4 5 6) 7 (8 9) 10), for instance. <br></blockquote><div><br></div><div><div>For that I think you want something like this:</div><div><font face="Courier New">(syntax-parse stx</font></div><div><font face="Courier New">  [(_ (~or (z ...)</font></div><div><font face="Courier New">           y)</font></div><div><font face="Courier New">      ...)</font></div><div><font face="Courier New">   #'(xf (yf y ... (zf z ...)))])</font></div></div></div></div></blockquote><div><br></div><div>Sorry I forgot an ellipsis.  I meant this:</div><div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div><font face="Courier New">(syntax-parse stx</font></div><div><font face="Courier New">  [(_ (~or (z ...)</font></div><div><font face="Courier New">           y)</font></div><div><font face="Courier New">      ...)</font></div><div><font face="Courier New">   #'(xf (yf y ... (zf z ...) ...))])</font></div></div></div><br><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div><div><br><div></div></div><div>Either that or you can use my version of syntax-parse with pattern-expanders and use ~seq-no-order:</div><div><a href="https://github.com/AlexKnauth/seq-no-order">https://github.com/AlexKnauth/seq-no-order</a></div><br><blockquote type="cite"><br>I have tried:<br><br>#lang racket<br><br>(require (for-syntax syntax/parse))<br><br>(define-syntax (x stx)<br><br>  (define-syntax-class binding<br>    #:description "binding list"<br>    (pattern (z:id ...)))<br><br>  (define-syntax-class or-binding<br>    #:description "binding or"<br>    (pattern (~or zb:binding y:id)<br>             #:with (z ...) #'(zb.z ...)))<br></blockquote><div><br></div><div>This won’t work because if the y:id pattern matches instead of the zb:binding pattern, then the zb.z attribute won’t be there.</div><div>Instead you probably wan’t this:</div><div><div> <font face="Courier New">(define-syntax-class or-binding<br>   #:description "binding or"<br>   (pattern zb:binding<br>            #:with (z ...) #'(zb.z ...))</font></div><div><font face="Courier New">   (pattern y:id</font></div><div><font face="Courier New">            #:with (z ...) #'(y)) ; or whatever, depending on what you want to do here</font></div><div><font face="Courier New">   )</font></div></div><br><blockquote type="cite"><br>  (syntax-parse stx<br>    [(_ (ob:or-binding ...) ...)<br>     #''ok<br>     #;#'(xf (yf ob.y ...) ...)<br>     #;#'(xf (yf ob.y ... (zf ob.z ...) ...) ...)]))<br><br>(define (xf . xs) xs)<br>(define (yf . ys) ys)<br>(define (zf . zs) zs)<br><br>(x (a))<br>(x (a b (c)))<br>(x (a b c (d e f) g h))<br><br>But while the pattern “appears” to match, I can’t seem to construct a template that is acceptable to syntax-parse, which doesn’t like the #:with clause on my syntax-class or-binding. I must be missing something.<br><br>-Kevin<br><br><br>____________________<br>  Racket Users list:<br>  <a href="http://lists.racket-lang.org/users">http://lists.racket-lang.org/users</a><br></blockquote></div><br></div></blockquote></div><br></body></html>