<div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">You can remove some of that repetition as well:</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">notes(N) when N < 6 -> 8;<br>notes(N) when N < 12 -> 4;<br>notes(_N) -> 2.<br><br>makePanPositionL(Notes, rapidlyleft2right, L) -> makePanPositionL(Notes, {rapidly, left2right}, L);<br>makePanPositionL(Notes, rapidlyright2left, L) -> makePanPositionL(Notes, {rapidly, right2left}, L);<br>makePanPositionL(Notes, {rapidly, Mode}, L) -> 2 * makePanPositionL(Notes, Mode, L);<br>makePanPositionL(Notes, left2right, [Cur|_]) -> Cur + notes(Notes);<br>makePanPositionL(Notes, right2left, [Cur|_]) -> Cur - notes(Notes).<br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Though this is golfing, so go for the solution you think is most easy to read. One advantage of the above model is that it might be better if you are toying with altering the scaling. The scaling parameters are in one place in this code, so alteration is easier. Also, you can simplify by using an erlang term rather than an atom via the {rapidly, Mode} trick. Or perhaps just {scale, 2, Mode} and then interpret this as</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">mpp(Notes, {scale, K, Mode}, L) -></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"> K * mpp(Notes, Mode, L).</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 13, 2019 at 4:06 PM Ivan Uemlianin <<a href="mailto:ivan@llaisdy.com">ivan@llaisdy.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 bgcolor="#FFFFFF">
Some people like it like that. The repitition on the RHS makes me
think there's room for more streamlining.<br>
<br>
<div class="gmail-m_3979435971927316005moz-cite-prefix">On 13/02/2019 15:02, Donald Steven
wrote:<br>
</div>
<blockquote type="cite">
Alas, that creates a different form of code sprawl, as in:<br>
<br>
<div style="color:rgb(255,255,255);background-color:rgb(0,36,81);font-family:Consolas,"Courier New",monospace;font-weight:normal;font-size:16px;line-height:22px;white-space:pre-wrap"><div><span style="color:rgb(187,218,255)">makePanPositionL</span><span style="color:rgb(255,255,255)">(</span><span style="color:rgb(255,157,164)">Notes</span><span style="color:rgb(255,255,255)">, </span><span style="color:rgb(209,241,169)">left2right</span><span style="color:rgb(255,255,255)">, [</span><span style="color:rgb(255,157,164)">Cur</span><span style="color:rgb(255,255,255)">|</span><span style="color:rgb(255,157,164)">_</span><span style="color:rgb(255,255,255)">]) </span><span style="color:rgb(235,187,255)">when</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,157,164)">Notes</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(153,255,255)"><</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,197,143)">6</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(153,255,255)">-></span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,157,164)">Cur</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(153,255,255)">+</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,197,143)">8</span><span style="color:rgb(255,255,255)">;</span></div><div><span style="color:rgb(187,218,255)">makePanPositionL</span><span style="color:rgb(255,255,255)">(</span><span style="color:rgb(255,157,164)">Notes</span><span style="color:rgb(255,255,255)">, </span><span style="color:rgb(209,241,169)">left2right</span><span style="color:rgb(255,255,255)">, [</span><span style="color:rgb(255,157,164)">Cur</span><span style="color:rgb(255,255,255)">|</span><span style="color:rgb(255,157,164)">_</span><span style="color:rgb(255,255,255)">]) </span><span style="color:rgb(235,187,255)">when</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,157,164)">Notes</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(153,255,255)"><</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,197,143)">12</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(153,255,255)">-></span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,157,164)">Cur</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(153,255,255)">+</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,197,143)">4</span><span style="color:rgb(255,255,255)">;</span></div><div><span style="color:rgb(187,218,255)">makePanPositionL</span><span style="color:rgb(255,255,255)">(</span><span style="color:rgb(255,157,164)">Notes</span><span style="color:rgb(255,255,255)">, </span><span style="color:rgb(209,241,169)">left2right</span><span style="color:rgb(255,255,255)">, [</span><span style="color:rgb(255,157,164)">Cur</span><span style="color:rgb(255,255,255)">|</span><span style="color:rgb(255,157,164)">_</span><span style="color:rgb(255,255,255)">]) </span><span style="color:rgb(153,255,255)">-></span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,157,164)">Cur</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(153,255,255)">+</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,197,143)">2</span><span style="color:rgb(255,255,255)">.</span></div><div><span style="color:rgb(187,218,255)">makePanPositionL</span><span style="color:rgb(255,255,255)">(</span><span style="color:rgb(255,157,164)">Notes</span><span style="color:rgb(255,255,255)">, </span><span style="color:rgb(209,241,169)">right2left</span><span style="color:rgb(255,255,255)">, [</span><span style="color:rgb(255,157,164)">Cur</span><span style="color:rgb(255,255,255)">|</span><span style="color:rgb(255,157,164)">_</span><span style="color:rgb(255,255,255)">]) </span><span style="color:rgb(235,187,255)">when</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,157,164)">Notes</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(153,255,255)"><</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,197,143)">6</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(153,255,255)">-></span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,157,164)">Cur</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(153,255,255)">-</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,197,143)">8</span><span style="color:rgb(255,255,255)">;</span></div><div><span style="color:rgb(187,218,255)">makePanPositionL</span><span style="color:rgb(255,255,255)">(</span><span style="color:rgb(255,157,164)">Notes</span><span style="color:rgb(255,255,255)">, </span><span style="color:rgb(209,241,169)">right2left</span><span style="color:rgb(255,255,255)">, [</span><span style="color:rgb(255,157,164)">Cur</span><span style="color:rgb(255,255,255)">|</span><span style="color:rgb(255,157,164)">_</span><span style="color:rgb(255,255,255)">]) </span><span style="color:rgb(235,187,255)">when</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,157,164)">Notes</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(153,255,255)"><</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,197,143)">12</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(153,255,255)">-></span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,157,164)">Cur</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(153,255,255)">-</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,197,143)">4</span><span style="color:rgb(255,255,255)">;</span></div><div><span style="color:rgb(187,218,255)">makePanPositionL</span><span style="color:rgb(255,255,255)">(</span><span style="color:rgb(255,157,164)">Notes</span><span style="color:rgb(255,255,255)">, </span><span style="color:rgb(209,241,169)">right2left</span><span style="color:rgb(255,255,255)">, [</span><span style="color:rgb(255,157,164)">Cur</span><span style="color:rgb(255,255,255)">|</span><span style="color:rgb(255,157,164)">_</span><span style="color:rgb(255,255,255)">]) </span><span style="color:rgb(153,255,255)">-></span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,157,164)">Cur</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(153,255,255)">-</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,197,143)">2</span><span style="color:rgb(255,255,255)">.</span></div><div><span style="color:rgb(187,218,255)">makePanPositionL</span><span style="color:rgb(255,255,255)">(</span><span style="color:rgb(255,157,164)">Notes</span><span style="color:rgb(255,255,255)">, </span><span style="color:rgb(209,241,169)">rapidlyleft2right</span><span style="color:rgb(255,255,255)">, [</span><span style="color:rgb(255,157,164)">Cur</span><span style="color:rgb(255,255,255)">|</span><span style="color:rgb(255,157,164)">_</span><span style="color:rgb(255,255,255)">]) </span><span style="color:rgb(235,187,255)">when</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,157,164)">Notes</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(153,255,255)"><</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,197,143)">6</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(153,255,255)">-></span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,157,164)">Cur</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(153,255,255)">+</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,197,143)">16</span><span style="color:rgb(255,255,255)">;</span></div><div><span style="color:rgb(187,218,255)">makePanPositionL</span><span style="color:rgb(255,255,255)">(</span><span style="color:rgb(255,157,164)">Notes</span><span style="color:rgb(255,255,255)">, </span><span style="color:rgb(209,241,169)">rapidlyleft2right</span><span style="color:rgb(255,255,255)">, [</span><span style="color:rgb(255,157,164)">Cur</span><span style="color:rgb(255,255,255)">|</span><span style="color:rgb(255,157,164)">_</span><span style="color:rgb(255,255,255)">]) </span><span style="color:rgb(235,187,255)">when</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,157,164)">Notes</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(153,255,255)"><</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,197,143)">12</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(153,255,255)">-></span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,157,164)">Cur</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(153,255,255)">+</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,197,143)">8</span><span style="color:rgb(255,255,255)">;</span></div><div><span style="color:rgb(187,218,255)">makePanPositionL</span><span style="color:rgb(255,255,255)">(</span><span style="color:rgb(255,157,164)">Notes</span><span style="color:rgb(255,255,255)">, </span><span style="color:rgb(209,241,169)">rapidlyleft2right</span><span style="color:rgb(255,255,255)">, [</span><span style="color:rgb(255,157,164)">Cur</span><span style="color:rgb(255,255,255)">|</span><span style="color:rgb(255,157,164)">_</span><span style="color:rgb(255,255,255)">]) </span><span style="color:rgb(153,255,255)">-></span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,157,164)">Cur</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(153,255,255)">+</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,197,143)">4</span><span style="color:rgb(255,255,255)">.</span></div><div><span style="color:rgb(187,218,255)">makePanPositionL</span><span style="color:rgb(255,255,255)">(</span><span style="color:rgb(255,157,164)">Notes</span><span style="color:rgb(255,255,255)">, </span><span style="color:rgb(209,241,169)">rapidlyright2left</span><span style="color:rgb(255,255,255)">, [</span><span style="color:rgb(255,157,164)">Cur</span><span style="color:rgb(255,255,255)">|</span><span style="color:rgb(255,157,164)">_</span><span style="color:rgb(255,255,255)">]) </span><span style="color:rgb(235,187,255)">when</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,157,164)">Notes</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(153,255,255)"><</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,197,143)">6</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(153,255,255)">-></span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,157,164)">Cur</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(153,255,255)">-</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,197,143)">16</span><span style="color:rgb(255,255,255)">;</span></div><div><span style="color:rgb(187,218,255)">makePanPositionL</span><span style="color:rgb(255,255,255)">(</span><span style="color:rgb(255,157,164)">Notes</span><span style="color:rgb(255,255,255)">, </span><span style="color:rgb(209,241,169)">rapidlyright2left</span><span style="color:rgb(255,255,255)">, [</span><span style="color:rgb(255,157,164)">Cur</span><span style="color:rgb(255,255,255)">|</span><span style="color:rgb(255,157,164)">_</span><span style="color:rgb(255,255,255)">]) </span><span style="color:rgb(235,187,255)">when</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,157,164)">Notes</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(153,255,255)"><</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,197,143)">12</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(153,255,255)">-></span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,157,164)">Cur</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(153,255,255)">-</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,197,143)">8</span><span style="color:rgb(255,255,255)">;</span></div><div><span style="color:rgb(187,218,255)">makePanPositionL</span><span style="color:rgb(255,255,255)">(</span><span style="color:rgb(255,157,164)">Notes</span><span style="color:rgb(255,255,255)">, </span><span style="color:rgb(209,241,169)">rapidlyright2left</span><span style="color:rgb(255,255,255)">, [</span><span style="color:rgb(255,157,164)">Cur</span><span style="color:rgb(255,255,255)">|</span><span style="color:rgb(255,157,164)">_</span><span style="color:rgb(255,255,255)">]) </span><span style="color:rgb(153,255,255)">-></span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,157,164)">Cur</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(153,255,255)">-</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,197,143)">4</span><span style="color:rgb(255,255,255)">.</span></div></div>
<br>
<br>
<div class="gmail-m_3979435971927316005moz-cite-prefix">On 2/13/2019 8.35 AM, Jesper Louis
Andersen wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif">On Wed,
Feb 13, 2019 at 1:51 PM Ivan Uemlianin <<a href="mailto:ivan@llaisdy.com" target="_blank">ivan@llaisdy.com</a>>
wrote:<br>
</div>
</div>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">This might be
cheating but I would avoid the branching altogether if <br>
poss., eg:<br>
<br>
PanPosition = CurrentPanPosition +
notes_to_pad(Notes),<br>
...<br>
<br>
notes_to_pad(N) where N < 6 -> 8;<br>
notes_to_pad(N) where N < 12 -> 4;<br>
notes_to_pad(_) -> 2.<br>
<br>
</blockquote>
<div><br>
</div>
<div>makePanPositionL(Notes, left2right, [Cur|_]) when
Notes < 6 -> Cur + 8;<br>
makePanPositionL(Notes, left2right, [Cur|_]) when Notes
< 12 -> Cur + 4;<br>
makePanPositionL(Notes, left2right,
[Cur|_]) -> Cur + 2.</div>
<div><br>
</div>
<div>
<div style="font-family:arial,helvetica,sans-serif" class="gmail_default">You can just lift everything
into a pattern match for this piece of code, which is
what I think I'd do. It makes the result far more
tabular, which in some cases is easier to read. There
may be other reasons in the code to not do this, but
as it was written, I think I'd pick the above as the
solution. YMMV of course.</div>
<br>
</div>
</div>
</div>
</div>
<br>
<fieldset class="gmail-m_3979435971927316005mimeAttachmentHeader"></fieldset>
<pre class="gmail-m_3979435971927316005moz-quote-pre">_______________________________________________
erlang-questions mailing list
<a class="gmail-m_3979435971927316005moz-txt-link-abbreviated" href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a>
<a class="gmail-m_3979435971927316005moz-txt-link-freetext" href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
</blockquote>
<br>
</blockquote>
<br>
<pre class="gmail-m_3979435971927316005moz-signature" cols="72">--
============================================================
Ivan A. Uemlianin PhD
Llaisdy
Ymchwil a Datblygu Technoleg Lleferydd
Speech Technology Research and Development
<a class="gmail-m_3979435971927316005moz-txt-link-abbreviated" href="mailto:ivan@llaisdy.com" target="_blank">ivan@llaisdy.com</a>
@llaisdy
<a href="http://llaisdy.wordpress.com" target="_blank">llaisdy.wordpress.com</a>
<a href="http://github.com/llaisdy" target="_blank">github.com/llaisdy</a>
<a class="gmail-m_3979435971927316005moz-txt-link-abbreviated" href="http://www.linkedin.com/in/ivanuemlianin" target="_blank">www.linkedin.com/in/ivanuemlianin</a>
festina lente
============================================================ </pre>
</div>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature">J.</div>