Raku By Example
View me onGitHub
# bind List
my @a := 1..Inf;
say @a[^10]; # 1 2 3 4 5 6 7 8 9 10 

my @primes  := @a.grep(*.is-prime);
say @primes[^10]; # 2 3 5 7 11 13 17 19 23 29

my @nprimes := @primes.map({ "{++state $n}: $_" });
.say for @nprimes[^10];

.say for (1..Inf
    ==> grep(*.is-prime)
    ==> map({ "{++state $n}: $_" })
    )[^10];

## bind array
my @a := (1, 2, 3);
say @a.WHAT;
say @a.elems;

my @b = (1, 2, 3);
@b[0] := my $x;
$x = 42;
say @b;

## bind scala
my $a;
my $b;

$b := $a;

$a = 7;
say $b;

$b = 8;
say $a;

## binding

my $original = 5;say $original;
my $mirror;
$original := $mirror;       # normal binding, done on runtime

say $mirror;

$original ::= $mirror;      # same thing, but done during compile time
say $mirror;
$original = 3;
say $mirror;                # prints 3
$original =:= $mirror;       # true, because their bound together
$original === $mirror;       # alsotrue, because content and type are equal

## seq loop

my @s := (loop { 42.say }).list;

@s[2]; # says 42 three times 
@s[1]; # does not say anything 
@s[4]; # says 42 two more times