Define a primitive data type: Difference between revisions

→‎{{header|Perl 6}}: don't pretend the closure is the most general form
(→‎{{header|Perl 6}}: don't pretend the closure is the most general form)
Line 855:
# dies, too small. string is 0 interpreted numerically</lang>
=={{header|Perl 6}}==
{{works with|Rakudo Star|2010-08}}
 
<lang perl6>subset OneToTen of Int where { 1 <= $^n <= 10 }..1
 
my OneToTen $n = 5;
$n += 6;</lang>
 
<code>{Here 1the <=result $^n11 <=fails 10to smartmatch against the range }(11)<code>1..10</code> returns a false value, so the second assignment throws an exception. You canmay use any unaryvalid functionsmartmatch inpredicate placewithin ofa <code>{ 1 <= $^n <= 10 }where</code> clause, so this,the forfollowing example,one-argument closure is also legal:
 
<lang perl6>subset Prime of Int where -> $n { $^n > 1 and ?(so $^n %% none 2 .. ($^n.sqrt)) }</lang>
 
=={{header|PicoLisp}}==
Anonymous user