September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,7 @@
func div_check(a, b){
var result = a/b
result.abs == Inf ? nil : result
}
 
say div_check(10, 2) # 5
say div_check(1, 0) # nil (detected)

View file

@ -0,0 +1,6 @@
func div_check(a, b){
Perl.eval("#{a} / #{b}")
}
 
say div_check(10, 2) # 5
say div_check(1, 0) # nil (detected)

View file

@ -1,13 +0,0 @@
func div(a, b){
try {
a / b
}
catch { |_, msg|
say "tried to divide by zero" if (msg ~~ /Division by zero/)
nil
}
}
say div(10, 2); # 5
say div(1, 0); # inf, 1/0 constants are substituted for infinity
say div(1.c, 0.c); # nil, and prints "tried to divide by zero" (complex numbers)