<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 7, 2014, at 1:41 AM, Kevin Forchione <<a href="mailto:lysseus@gmail.com">lysseus@gmail.com</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;"><br><div><div>On Aug 6, 2014, at 11:02 AM, Alexander D. Knauth <<a href="mailto:alexander@knauth.org">alexander@knauth.org</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-family: Georgia; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class="Apple-interchange-newline">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" style="font-family: Georgia; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><blockquote type="cite" style="font-family: Georgia; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><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.<span class="Apple-converted-space"> </span><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 style="font-family: Georgia; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br></div><div style="font-family: Georgia; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Sorry I forgot an ellipsis. I meant this:</div><div style="font-family: Georgia; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><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></blockquote></div><div><br></div><div>Remarkably difficult just to parse what amounts to nested lists! This doesn’t quite do what I want either. For instance:</div><div><br></div><div><div>#lang racket</div><div><br></div><div>(require (for-syntax syntax/parse))</div><div><br></div><div>#;(define-syntax (x stx)</div><div> </div><div> (define-syntax-class binding</div><div> #:description "binding list"</div><div> (pattern (z:number ...)))</div><div> </div><div> (syntax-parse stx</div><div> [(_ b:binding ...)</div><div> #'(list (list b.z ...) ...)]))</div><div><br></div><div>#;(define-syntax (x stx)</div><div> </div><div> (define-syntax-class lbinding</div><div> #:description "binding list"</div><div> (pattern (z:number ...)))</div><div> </div><div> (define-syntax-class orbinding</div><div> #:description "binding or"</div><div> (pattern (y:number ...)</div><div> #:with (z ...) #'(y ...))</div><div> (pattern (lb:lbinding)</div><div> #:with (z ...) #'(lb.z ...)))</div><div> </div><div> (syntax-parse stx</div><div> [(_ ob:orbinding ...)</div><div> #'(list (list ob.z ...) ...)]))</div><div><br></div><div>#;(define-syntax (x stx)</div><div> </div><div> (define-syntax-class lbinding</div><div> #:description "binding list"</div><div> (pattern (z:number ...)))</div><div> </div><div> (define-syntax-class orbinding</div><div> #:description "binding or"</div><div> (pattern (y:number ...)</div><div> #:with (z ...) #'(y ...))</div><div> (pattern (lb:lbinding)</div><div> #:with (z ...) #'(lb.z ...)))</div><div> </div><div> (syntax-parse stx</div><div> [(_ ob:orbinding ...)</div><div> #'(list (list ob.z ...) ...)]))</div><div><br></div><div>(define-syntax (x stx)</div><div> (syntax-parse stx</div><div> [(_ (~or (z ...)</div><div> y)</div><div> ...)</div><div> #'(list (list y ... (list z ...) ...))]))</div><div><br></div><div>(x (1 2 3 4) (5 (6 7) 8))</div><div><br></div><div>expands to: (list (list (list 1 2 3 4) (list 5 (6 7) 8))))) instead of (list (list (list 1 2 3 4) (list 5 (list 6 7) 8))))). </div><div><br></div><div>-Kevin</div></div><br></div></blockquote></div><br><div>Do you want something like this then:</div><div><font face="Courier New">(syntax-parse stx</font></div><div><font face="Courier New"> [(_ (~or ((((e ...) ...) ...) ...)</font></div><div><span style="font-family: 'Courier New';"> </span><font face="Courier New">(((d ...) ...) ...)</font></div><div><font face="Courier New"> ((c ...) ...)</font></div><div><font face="Courier New"> (b ...)</font></div><div><font face="Courier New"> a)</font></div><div><font face="Courier New"> . . .)</font></div><div><font face="Courier New"> #’(list (list a ... (list b ... (list c ... (list d ... (list e ...) ...) ...) ...) ...) ...)])</font></div><div>Except going infinitely? For that I think you would need a recursive helper function. </div><div><br></div><div>Or do you want to just replace all instances of (a ...) with (list a ...) ?:</div><div><font face="Courier New">(define-syntax-class thing</font></div><div><font face="Courier New"> #:attributes (norm)</font></div><div><font face="Courier New"> [pattern (a:thing ...)</font></div><div><font face="Courier New"> #:with norm (list a.norm ...)]</font></div><div><font face="Courier New"> [pattern a</font></div><div><font face="Courier New"> #:with norm a])</font></div><div><br></div><div>Or what?</div><div><br></div><div><br></div></body></html>