( 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. 0 but True
--- my $role = role { method Bool { True }}
You can do that manually if you want. 0 but role { method Bool { True }}
--- 0 but True
Is roughly equivalent to: do {
my constant but-true = anon role { method Bool { True }}
my $class = anon class :: is Int does but-true {}
$class.new( 0 )
} my &infix:< · > = &infix:< × >;
(After all `×` itself is just an alias of `*` in the source for Rakudo.) sub infix:< · > (+@vals)
is equiv(&[×]) # uses the same precedence level etc.
is assoc<chaining> # may not be necessary given previous line
{
[×] @vals # reduction using infix operator
}
I made it chaining for the same reason `+` and `×` are chaining. # I don't know what precedence level it is supposed to be
proto infix:< ∧ > (|) is tighter(&[×]) {*}
multi infix:< ∧ > (
Numeric $l,
Numeric $r,
) {
$l × $r
}
multi infix:< ∧ > (
Vector $l, # need to define this somewhere, or use List/Array
Vector $r,
) {
…
}
If it was as simple as just a normal cross product, that would have been easy. [[1,2,3],[4,5,6]] »×« [[10,20,30],[40,50,60]]
# [[10,40,90],[160,250,360]]
# generate a synthetic `»×«` operator, and give it an alias
my &infix:< ∧ > = &infix:< »×« >;
[[1,2,3],[4,5,6]] ∧ [[10,20,30],[40,50,60]]
# [[10,40,90],[160,250,360]]
Of course, I'm fairly confident that is wrong. say π ≤ 3+⅘ ≤ τ
# True
say π² ÷ 4
# 2.4674011002723395 # this assumes that ϕ, ψ, and θ have already been set
my \cϕ = ϕ.cos; my \sϕ = ϕ.sin;
my \cψ = ψ.cos; my \sψ = ψ.sin;
my \cθ = θ.cos; my \sθ = θ.sin;
my \alpha = [ cψ×cϕ−cθ×sϕ×sψ, cψ×sϕ+cθ×cϕ×sψ, sψ×sθ;
−sψ×cϕ−cθ×sϕ×cψ, −sψ×sϕ+cθ×cϕ×cψ, cψ×sθ;
sθ×sϕ, −sθ×cϕ, cθ];
I'm not sure if using × helps or hurts in this case since I'm not really experienced in this area. say "ϕψθ".uniprops;
# (Ll Ll Ll)
---
I know I'm tired of seeing it, I'm sure others are as well.