Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/Collections/Raku/collections-1.raku
Normal file
16
Task/Collections/Raku/collections-1.raku
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# Array
|
||||
my @array = 1,2,3;
|
||||
@array.push: 4,5,6;
|
||||
|
||||
# Hash
|
||||
my %hash = 'a' => 1, 'b' => 2;
|
||||
%hash<c d> = 3,4;
|
||||
%hash.push: 'e' => 5, 'f' => 6;
|
||||
|
||||
# SetHash
|
||||
my $s = SetHash.new: <a b c>;
|
||||
$s ∪= <d e f>;
|
||||
|
||||
# BagHash
|
||||
my $b = BagHash.new: <b a k l a v a>;
|
||||
$b ⊎= <a b c>;
|
||||
11
Task/Collections/Raku/collections-2.raku
Normal file
11
Task/Collections/Raku/collections-2.raku
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# List
|
||||
my @list := 1,2,3;
|
||||
my @newlist := |@list, 4,5,6; # |@list will slip @list into the surrounding list instead of creating a list of lists
|
||||
|
||||
# Set
|
||||
my $set = set <a b c>;
|
||||
my $newset = $set ∪ <d e f>;
|
||||
|
||||
# Bag
|
||||
my $bag = bag <b a k l a v a>;
|
||||
my $newbag = $bag ⊎ <b e e f>;
|
||||
2
Task/Collections/Raku/collections-3.raku
Normal file
2
Task/Collections/Raku/collections-3.raku
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
my $tail = d => e => f => Nil;
|
||||
my $new = a => b => c => $tail;
|
||||
3
Task/Collections/Raku/collections-4.raku
Normal file
3
Task/Collections/Raku/collections-4.raku
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
class Something { has $.foo; has $.bar };
|
||||
my $obj = Something.new: foo => 1, bar => 2;
|
||||
my $newobj = $obj but role { has $.baz = 3 } # anonymous mixin
|
||||
Loading…
Add table
Add a link
Reference in a new issue