( 2..∞ ).grep( *.is-prime )
This has the benefit that it doesn't generate any values until you ask for them. Also If you don't do anything to cache the values, they will be garbage collected as you go. 2, 4, 8 ... *
The `...` operator only deduces arithmetic, or geometric changes for up-to the previous 3 values. 2, 4, 8, * × 2 ... *
Since each value is just double the previous one, it can figure that out. 2, 4, 9 ... *
Unable to deduce arithmetic or geometric sequence from: 2, 4, 9
Did you really mean '..'?
in block at ./example.raku line 1
So I really don't understand how you would be horrified. say [+] 1..10000000000000000000000000000000000000000000
Which will result in you getting this back in a fraction of a second role Singleton {
method new (|) {
once callsame
}
}
class Foo does Singleton {
has $.n is required
}
say Foo.new( n => 1 ).n;
say Foo.new( n => 2 ).n;
That prints `1` twice. my $string = 'AAABBBCCC';
say $string ~~ /
^
# match at least one A
# store the result in a named sub-entry
$<A> = [ A+ ]
{} # update result object
# create a lexical var named $repetition
:my $repetition = $<A>.chars(); # <- embedded Raku syntax
# match B and then C exactly $repetition times
$<B> = [ B ** {$repetition} ]
$<C> = [ C ** {$repetition} ]
$
/;
Result: 「AAABBBCCC」
A => 「AAA」
B => 「BBB」
C => 「CCC」
The result is actually a very extensive object that has many ways to interrogate it. What you see above is just a built-in human readable view of it. while (<>) { ($h{$_}++ == 1) && push (@outputarray, $_); };
Would be written as the following in Raku: my @output-array = lines.unique; for @a { .say }
So this works in basically the same way: my $lambda = { .say }
@a.map( $lambda );
Or that the pointy block syntax … for @a -> $item { say $item }
… works on every keyword of the form `KEYWORD (CONDITION) {BLOCK}`. if $a.method() -> $result { say $result }
The pointy block is of course also a lambda. my $lambda = -> $result { say $result }
--- use v5.30;
use v2019;
Basically have both of those lines do the same thing. use Perl v2019;
(I actually considered posting a module that would make that work.)
I know I'm tired of seeing it, I'm sure others are as well.