sub infix:<ρ>($shape, @values) {
Array.new(:$shape, ([∘] $shape.skip.map: { *.rotor($_) })(@values));
}
sub prefix:<ι>(UInt $x) { ^$x }
sub infix:<ι>(@xs, $x) { @xs.first(:k, $x) }
sub infix:<⁄>($bs, $xs) { ([Z] $xs, $bs).map({ .[0] if .[1] }) }
sub infix:<↑>(Int $x, @xs) { $x ≥ 0 ?? @xs.head($x) !! @xs.tail($x.abs) }
sub infix:<↓>(Int $x, @xs) { $x ≥ 0 ?? @xs.tail(* - $x) !! @xs.head(* + $x) }
say (4, 2) ρ (25, 60, 33, 47, 11, 44, 53, 2);
my @vals := (22, 37, 41, 19, 54, 11, 34);
my @sals := (4225, 1619, 3706, 2240, 2076, 1389, 3916, 3918, 4939, 2735);
my @cats := (3, 1, 3, 2, 2, 1, 3, 3, 3, 2 );
say (@cats «==» 2) ⁄ @sals;
say (@vals «>» 35) ⁄ ι@vals;
my @area := (17, 50, 59, 84, 89);
my @discount := (9, 8, 6, 5, 4, 2);
my $D := 84;
say $D ∈ @area;
say @discount[@area ι $D];
my @list := (15, 40, 63, 18, 27, 40, 33, 29, 40, 88);
say 4 ↑ @list;
say @list[ι 4];
say 5 ↓ @list;
my @tome := (56, 59, 67, 64, 60, 61, 68, 73, 78, 75, 81, 84);
say (1↓@tome) «-» (-1↓@tome);
Last active
January 20, 2021 06:16
-
-
Save 0racle/b2b2514f8b9ff056263385fe1b333b17 to your computer and use it in GitHub Desktop.
Dyalog in Raku
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment