<div dir="ltr"><div>Could it be so that you can shortcut in the expected order (left to right)?</div><div><br></div><div>Left associative:</div><div>a && b && c = (a && b) && c which means going into a && b, which means going into a, and if it is False, then going up in the expression tree.</div><div><br></div><div>If it is right associative:</div><div>a && b && c = a && (b && c), which means going into a, and if it is False, you are done.</div><div><br></div><div>If you have a conjunction of n booleans, the complexity of evaluating this expression is linear with respect to the position of the first False (in the case of &&). In the left-associative case, it is linear in the number of &&s.<br></div><div><br></div><div>Just a guess. But you got me interested now.</div><div><br></div><div>Does anyone have the real explanation?</div><div><br></div><div>Cheers,</div><div><br></div><div>Ivan<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 11 Apr 2019 at 22:13, Richard Eisenberg <<a href="mailto:rae@richarde.dev" target="_blank">rae@richarde.dev</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">Hi café,<br>
<br>
Why are && and || in the Prelude right-associative? This contradicts my expectation and the way these work in other languages. That said, I can't think of any harm in it. This came up from a question asked by a student, and I have no idea why the design is this way.<br>
<br>
Thanks,<br>
Richard<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div>