<div dir="ltr"><div>Hi Iain,</div><div><br></div><div>Wasn't aware of the chain srfi. Interesting.</div><div>Since I'm coming more from clojure I guess I'll focus a bit more on the "as->", "->" and "->>".<br></div><div>Could try fiddling with these from Monday on and will keep you posted on the process.</div><div><br></div><div>The "(x ~> a _ b ~> c _ )" form seems kinda too much though, adding infix notation to the mix<font face="Noto Sans, Arial, sans-serif" color="#1a1a1b"><span style="font-size:14px"><br></span></font></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, 19 Sep 2020 at 19:37, Iain Duncan <<a href="mailto:iainduncanlists@gmail.com">iainduncanlists@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi colleagues, I'm trying to figure out how to build a couple of threading macros that would be very helpful in Max/MSP for Scheme for Max, but it is frankly over my head right now. Working it out will be a good exercise but I figured I would post here in case this is trivial for some macro experts in S7 and they are willing to share something I can study. <div><br></div><div>I want to implement something like <span style="color:rgb(26,26,27);font-family:"Noto Sans",Arial,sans-serif;font-size:14px">srfi-197, where it is called "chain". (but srfi-197 uses syntax-case and syntax-rules)</span></div><div><span style="color:rgb(26,26,27);font-family:"Noto Sans",Arial,sans-serif;font-size:14px"><br></span></div><div><span style="color:rgb(26,26,27);font-family:"Noto Sans",Arial,sans-serif;font-size:14px">so from the docs there: </span></div><div><div><span style="color:rgb(26,26,27);font-family:"Noto Sans",Arial,sans-serif;font-size:14px"></span></div><div><pre style="border-color:inherit;box-sizing:inherit;font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;padding:16px;background-color:rgb(246,248,250);color:rgb(31,31,31);direction:ltr;line-height:1.45;overflow:auto;border-radius:3px"><code style="border:0px none;box-sizing:inherit;font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;padding:0px;border-radius:3px;direction:ltr;line-height:inherit;margin:0px;overflow:visible;word-spacing:normal;word-break:normal;display:inline;background:transparent none repeat scroll 0% 0%;color:inherit"><span style="border-color:inherit;box-sizing:inherit"><span style="border-color:inherit;box-sizing:inherit;margin-bottom:0px">(chain x (a b _)) </span><span style="border-color:inherit;box-sizing:inherit;color:rgb(106,115,125);margin-bottom:0px">; => (a b x)</span></span><br style="border-color:inherit;box-sizing:inherit"><span style="border-color:inherit;box-sizing:inherit"><span style="border-color:inherit;box-sizing:inherit;margin-bottom:0px">(chain (a b) (c _ d) (e f _)) </span><span style="border-color:inherit;box-sizing:inherit;color:rgb(106,115,125);margin-bottom:0px">; => (let* ((x (a b)) (x (c x d))) (e f x))</span></span><br style="border-color:inherit;box-sizing:inherit"><span style="border-color:inherit;box-sizing:inherit"><span style="border-color:inherit;box-sizing:inherit;margin-bottom:0px">(chain (a) (b _ _) (c _)) </span><span style="border-color:inherit;box-sizing:inherit;color:rgb(106,115,125);margin-bottom:0px">; => (let*-values (((x1 x2) (a)) ((x) (b x1 x2))) </span><span style="border-color:inherit;box-sizing:inherit;color:rgb(106,115,125);margin-bottom:0px">(c x))</span></span></code></pre></div></div><div><br></div><div><font face="Noto Sans, Arial, sans-serif" color="#1a1a1b"><span style="font-size:14px">But what I'd really to make on top of that is a version for allows one to use this for one liners in Max without inner parens, so something like this, where the macro is ~></span></font></div><div><font face="Noto Sans, Arial, sans-serif" color="#1a1a1b"><span style="font-size:14px"><br></span></font></div><div><font face="Noto Sans, Arial, sans-serif" color="#1a1a1b"><span style="font-size:14px">(x ~> a _ b ~> c _ )</span></font></div><div><font face="Noto Sans, Arial, sans-serif" color="#1a1a1b"><span style="font-size:14px">becomes something equivalent of:</span></font></div><div><font face="Noto Sans, Arial, sans-serif" color="#1a1a1b"><span style="font-size:14px">(c (a (eval x) b))</span></font></div><div><font face="Noto Sans, Arial, sans-serif" color="#1a1a1b"><span style="font-size:14px"><br></span></font></div><div><font face="Noto Sans, Arial, sans-serif" color="#1a1a1b"><span style="font-size:14px">Because Scheme for Max will take a max message and treat it as code to be wrapped in outer parens and then eval'd, this will let people do very useful things in one short max message (where say $i and $i2 come from another max message sending to it:</span></font></div><div><font face="Noto Sans, Arial, sans-serif" color="#1a1a1b"><span style="font-size:14px"><br></span></font></div><div><font face="Noto Sans, Arial, sans-serif" color="#1a1a1b"><span style="font-size:14px">$i1 ~> + 10 _ ~> / $i2 _ </span></font></div><div><font face="Noto Sans, Arial, sans-serif" color="#1a1a1b"><span style="font-size:14px"><br></span></font></div><div><font face="Noto Sans, Arial, sans-serif" color="#1a1a1b"><span style="font-size:14px">If anyone has suggestions or feels like helping that would be amazing. thanks!</span></font></div></div>
_______________________________________________<br>
Cmdist mailing list<br>
<a href="mailto:Cmdist@ccrma.stanford.edu" target="_blank">Cmdist@ccrma.stanford.edu</a><br>
<a href="https://cm-mail.stanford.edu/mailman/listinfo/cmdist" rel="noreferrer" target="_blank">https://cm-mail.stanford.edu/mailman/listinfo/cmdist</a><br>
</blockquote></div>