Another update from ingydotnet^djgoku

This commit is contained in:
Ingy döt Net 2015-11-18 06:14:39 +00:00
parent 91df62d461
commit 948b86eafa
7604 changed files with 108452 additions and 22726 deletions

View file

@ -0,0 +1 @@
IsNaN(x)

View file

@ -0,0 +1,7 @@
my Int:D $i = 1; # if $i has to be defined you must provide a default value
multi sub foo(Int:D $i where * != 0){ (0..100).roll / $i } # we will never divide by 0
multi sub foo(Int:U $i){ die 'WELP! $i is undefined' } # because undefinedness is deadly
multi sub foo(Int:_ where * == 0){ die q{I'm sorry, Dave, I'm afraid I can't do that.} }
with $i { say 'defined' } # as "if" is looking for Bool::True, "with" is looking for *.defined
with 0 { say '0 may not divide but it is defined' }

View file

@ -0,0 +1,17 @@
my $is-defined = 1;
my $ain't-defined = Any;
my $doesn't-matter;
my Any:D $will-be-defined = $ain't-defined // $is-defined // $doesn't-matter;
my @a-mixed-list = Any, 1, Any, 'a';
$will-be-defined = [//] @a-mixed-list; # [//] will return the first defined value
my @a = Any,Any,1,1;
my @b = 2,Any,Any,2;
my @may-contain-any = @a >>//<< @b; # contains: [2, Any, 1, 1]
sub f1(){Failure.new('WELP!')};
sub f2(){ $_ ~~ Failure }; # orelse will kindly set the topic for us
my $s = (f1() orelse f2()); # Please note the parentheses, which are needed because orelse is
# much looser then infix:<=> .
dd $s; # this be Bool::False

View file

@ -1,23 +1,20 @@
/*REXX program to test if a variable is defined. */
/*REXX program test if a (REXX) variable is defined or not defined. */
tlaloc = "rain god of the Aztecs." /*assign a value to the Aztec rain god.*/
/*check if the rain god is defined. */
y= 'tlaloc'
if symbol(y)=="VAR" then say y ' is defined.'
else say y "isn't defined."
tlaloc = "rain god of the Aztecs."
/*check if the fire god is defined. */
y= 'xiuhtecuhtli' /*assign a value to the Aztec file god.*/
if symbol(y)=="VAR" then say y ' is defined.'
else say y "isn't defined."
/*check if the rain god is defined.*/
y='tlaloc'
if symbol(y)=="VAR" then say y 'is defined.'
else say y "ain't defined."
/*check if the fire god is defined.*/
y='xiuhtecuhtli'
if symbol(y)=="VAR" then say y 'is defined.'
else say y "ain't defined."
drop tlaloc /*un-define the TLALOC variable. */
/*check if the rain god is defined.*/
y='tlaloc'
if symbol(y)=="VAR" then say y 'is defined.'
else say y "ain't defined."
drop tlaloc /*un─define the TLALOC REXX variable.*/
/*check if the rain god is defined. */
y= 'tlaloc'
if symbol(y)=="VAR" then say y ' is defined.'
else say y "isn't defined."
/*stick a fork in it, we're all done. */