You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just looked over the examples, and it maybe it's me being obsessed with modulo-related code examples — probably — but it would seem that all three of euclid-gcd.007, fizzbuzz.007, and nicomachus.007 would benefit from having infix:<%> (and infix:<%%>) built into the language.
So,
Let's implement those.
Let's not implement infix:</> for now. I'm still bothered by the things described in this comment.
There's the risk of a division by zero, even with infix:<%> and infix:<%%>. So we'll need a new 007-exception type, and we'll need tests that try catching it.
After we have the operators, we should go back and make the examples prettier.
The text was updated successfully, but these errors were encountered:
There's the risk of a division by zero, even with infix:<%> and infix:<%%>. So we'll need a new 007-exception type, and we'll need tests that try catching it.
Actually, I ended up just using the Perl 6 exception (X::Numeric::DivideByZero) for now. We can save the custom-exceptions work for some later time, when we do it across the board.
Turns out we did — the above commit range contains tests for negative divisor. Also, Perl 6 and Python agree that 5 % -2 = 1. Guido has a blog post explaining why this is sane semantics.
JavaScript on the other hand consider 5 % -2 to be -1.
I just looked over the examples, and it maybe it's me being obsessed with modulo-related code examples — probably — but it would seem that all three of
euclid-gcd.007
,fizzbuzz.007
, andnicomachus.007
would benefit from havinginfix:<%>
(andinfix:<%%>
) built into the language.So,
infix:</>
for now. I'm still bothered by the things described in this comment.infix:<%>
andinfix:<%%>
. So we'll need a new 007-exception type, and we'll need tests that try catching it.The text was updated successfully, but these errors were encountered: