Slide 1

Slide 1 text

Raku Next Steps: Hyperactive Metang ( Starting to think in Raku )
 
 { with Meta-Operators like Z,X,Reduce,Hyper } [ Part 1 of a "Intermediate Raku" class ] The Perl and Raku Conference
 
 2024-06-27

Slide 2

Slide 2 text

Raku Next Steps: Hyperactive Metang PLEASE DOWNLOAD THESE SLIDES! 
 http://speakerdeck.com/util
 <<< >>> >>> <<<

Slide 3

Slide 3 text

ChatGPT ABEND:
 Failed to catch Pokémon

Slide 4

Slide 4 text

Preface

Slide 5

Slide 5 text

Bruce Gray (Util)

Slide 6

Slide 6 text

Raku

Slide 7

Slide 7 text

Raku = Perl

Slide 8

Slide 8 text

Raku = Perl + Awesome

Slide 9

Slide 9 text

pruh-nuhn-see-ey-shuhn [ rah-koo ] / ˈrɑ ku / [ rey-koo ] / ˈreɪ ku / 9

Slide 10

Slide 10 text

10 • https://glot.io/new/raku for online coding
 • Mac: brew install rakudo-star • Windows/Linux: https://rakudo.org/downloads • Docker: • REPL on any system: • docker run --rm -it rakudo-star • Script on Mac or Unix: • docker run --rm -v "$(pwd):/script" rakudo-star raku /script/a.raku • Script on Windows: • docker run --rm -v "%cd%:/script" rakudo-star raku /script/a.raku Run online, or install locally

Slide 11

Slide 11 text

Volume

Slide 12

Slide 12 text

Plan9! • Operator review • Meta-ops: • reduce • produce • zip • cross • hyper/race • the good, the bad, and the beautiful

Slide 13

Slide 13 text

Plan9! • Combining meta-ops • Surprises • Uh-ohs

Slide 14

Slide 14 text

Plan9! • Combining meta-ops • Surprises • Uh-ohs • TIMTOWTDI • WTDI

Slide 15

Slide 15 text

Operators

Slide 16

Slide 16 text

Operators See 2023 "Raku for Beginners" class: https://youtu.be/eb-j1rxs7sc
 https://youtu.be/2UO-LEhOkiM

Slide 17

Slide 17 text

Different meanings by position In Perl: / Division: if ($x / 3 > 5) {…} Regex start: if ($x =~ /abc/) {…} 17

Slide 18

Slide 18 text

Different meanings by position say 15 < 17 && 17 > 16; say < Alice Bob Carol David >; 18

Slide 19

Slide 19 text

Different meanings by position say 15 < 17 && 17 > 16; say ; 19

Slide 20

Slide 20 text

ASCII upgrades, Unicode Fallbacks « << » >> ≠ != ≤ <= ≥ >= ∈ (elem) ∋ (cont) 20

Slide 21

Slide 21 text

https://www.ozonehouse.com/ mark/periodic/

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

+-*/ Math ~ String && || Logical ! + ? Coercion & | Junction ∪ ∩ ∈ Set .. ^..^ Range , List := Binding !!! Stub 27

Slide 28

Slide 28 text

Pre fi x

Slide 29

Slide 29 text

Post fi x

Slide 30

Slide 30 text

In fi x

Slide 31

Slide 31 text

In fi x, Pre fi x, Post fi x Operators say 5 ** 2; # power(5, 2) say 2 + 2; # add(2, 2) say +( '9' ~ '9' ); # make_numeric( # concat('9','9') # ) $z++; # $z = add($z, 1) 31

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

Meta-ops we know op=

Slide 34

Slide 34 text

Perl, C, so many others… $foo = $foo + 5; $foo += 5; 34

Slide 35

Slide 35 text

Perl, C, so many others… $foo = $foo + 5; $foo += 5; # op= $foo >>= 1; 35

Slide 36

Slide 36 text

Perl, C, so many others… $foo = $foo + 5; $foo += 5; # op= $foo >>= 1; $foo max= 7; 36

Slide 37

Slide 37 text

Perl, C, so many others… $foo = $foo + 5; $foo += 5; # op= $foo >>= 1; $foo max= 7; $foo = $foo yourop $bar; $foo yourop= $bar; 37

Slide 38

Slide 38 text

Reduce

Slide 39

Slide 39 text

sub sum (@ns) { | sub product (@ns) { | sub join (@ss) { my $total = 0; | my $prod = 1; | my $ret = ''; for @ns -> $n { | for @ns -> $n { | for @ss -> $s {. $total += $n; | $prod *= $n; | $ret ~= $s; } | } | } return $total; | return $prod; | return $ret; } | } | } 39

Slide 40

Slide 40 text

sub sum (@ns) { | sub product (@ns) { | sub join (@ss) { my $total = 0; | my $prod = 1; | my $ret = ''; for @ns -> $n { | for @ns -> $n { | for @ss -> $s {. $total += $n; | $prod *= $n; | $ret ~= $s; } | } | } return $total; | return $prod; | return $ret; } | } | } 40

Slide 41

Slide 41 text

sub sum (@ns) { | sub product (@ns) { | sub join (@ss) { my $total = 0; | my $prod = 1; | my $ret = ''; for @ns -> $n { | for @ns -> $n { | for @ss -> $s {. $total += $n; | $prod *= $n; | $ret ~= $s; } | } | } return $total; | return $prod; | return $ret; } | } | } 41

Slide 42

Slide 42 text

sub sum (@ns) { | sub product (@ns) { | sub join (@ss) { my $acc = 0; | my $acc = 1; | my $acc = ''; for @ns -> $n { | for @ns -> $n { | for @ss -> $s {. $acc += $n; | $acc *= $n; | $acc ~= $s; } | } | } return $acc; | return $acc; | return $acc; } | } | } 42

Slide 43

Slide 43 text

sub sum (@ns) { | sub product (@ns) { | sub join (@ss) { my $acc = 0; | my $acc = 1; | my $acc = ''; for @ns { | for @ns { | for @ss { . $acc += $_; | $acc *= $_; | $acc ~= $_; } | } | } return $acc; | return $acc; | return $acc; } | } | } 43

Slide 44

Slide 44 text

sub sum (@x) { | sub product (@x) { | sub join (@x) { my $acc = 0; | my $acc = 1; | my $acc = ''; for @x { | for @x { | for @x { . $acc += $_; | $acc *= $_; | $acc ~= $_; } | } | } return $acc; | return $acc; | return $acc; } | } | } 44

Slide 45

Slide 45 text

sub sum (@x) { | sub product (@x) { | sub join (@x) { my $a = 0; | my $a = 1; | my $a = ''; for @x { | for @x { | for @x { . $a += $_; | $a *= $_; | $a ~= $_; } | } | } return $a; | return $a; | return $a; } | } | } 45

Slide 46

Slide 46 text

sub sum (@x) { | sub product (@x) { | sub join (@x) { my $a = 0; | my $a = 1; | my $a = ''; | | $a += $_ for @x;| $a *= $_ for @x; | $a ~= $_ for @x; | | return $a; | return $a; | return $a; } | } | } 46

Slide 47

Slide 47 text

sub sum (@x) { | sub product (@x) { | sub join (@x) { my $a = 0; | my $a = 1; | my $a = ''; | | $a += $_ for @x;| $a *= $_ for @x; | $a ~= $_ for @x; | | return $a; | return $a; | return $a; } | } | } 47

Slide 48

Slide 48 text

sub sum (@x) { my $a = 0; $a += $_ for @x; return $a; } 48

Slide 49

Slide 49 text

sub sum (@x) { my $a = 0; $a = $a + $_ for @x; return $a; } 49

Slide 50

Slide 50 text

sub reduce (@x) { my $a = 0; $a = $a + $_ for @x; return $a; } 50

Slide 51

Slide 51 text

sub reduce (@x) { my $a = $init; $a = $a + $_ for @x; return $a; } 51

Slide 52

Slide 52 text

sub reduce (@x, $init) { my $a = $init; $a = $a + $_ for @x; return $a; } 52

Slide 53

Slide 53 text

sub reduce (@x, $init) { my $a = $init; $a = operation($a, $_) for @x; return $a; } 53

Slide 54

Slide 54 text

sub reduce (&operation, @x, $init) { my $a = $init; $a = operation($a, $_) for @x; return $a; } 54

Slide 55

Slide 55 text

sub sum (@x) { | sub product (@x) { | sub join (@x) { my $a = 0; | my $a = 1; | my $a = ''; | | $a += $_ for @x;| $a *= $_ for @x; | $a ~= $_ for @x; | | return $a; | return $a; | return $a; } | } | } 55

Slide 56

Slide 56 text

sub sum (@x) { | sub product (@x) { | sub join (@x) { my $a = 0; | my $a = 1; | my $a = ''; | | $a += $_ for @x;| $a *= $_ for @x; | $a ~= $_ for @x; | | return $a; | return $a; | return $a; } | } | } my $total = reduce { $^a + $^b }, @fees, 0; my $factorial = reduce { $^a * $^b }, [1..5], 1; my $joined = reduce { $^a ~ $^b }, @out, ''; 56

Slide 57

Slide 57 text

sub sum (@x) { return reduce { $^a + $^b }, @x, 0; } sub product (@x) { return reduce { $^a * $^b }, @x, 1; } sub join (@x) { return reduce { $^a ~ $^b }, @x, ""; } my $total = sum(@fees); my $factorial = product([1..5]); my $joined = join(@out); 57

Slide 58

Slide 58 text

sub sum (@x) { return reduce { $^a + $^b }, @x, 0; } sub product (@x) { return reduce { $^a * $^b }, @x, 1; } sub join (@x) { return reduce { $^a ~ $^b }, @x, ""; } my $total = sum(@fees); my $factorial = product([1..5]); my $joined = join(@out); Javascript: sum = arr.reduce((a,x) => a+x, 0); 58

Slide 59

Slide 59 text

sub reduce (&operation, @x, $init) { my $a = $init; $a = operation($a, $_) for @x; . return $a; } 59

Slide 60

Slide 60 text

sub reduce (&operation, @x, $init) { my $a = @x.head; $a = operation($a, $_) for @x.skip; return $a; } 60

Slide 61

Slide 61 text

sub reduce (&operation, @x) { my $a = @x.head; $a = operation($a, $_) for @x.skip; return $a; } 61

Slide 62

Slide 62 text

sub sum (@x) { return reduce { $^a + $^b }, @x, 0; } sub product (@x) { return reduce { $^a * $^b }, @x, 1; } sub join (@x) { return reduce { $^a ~ $^b }, @x, ""; } my $total = sum(@fees); my $factorial = product([1..5]); my $joined = join(@out); 62

Slide 63

Slide 63 text

sub sum (@x) { return reduce { $^a + $^b }, @x, 0; } sub product (@x) { return reduce { $^a * $^b }, @x, 1; } sub join (@x) { return reduce { $^a ~ $^b }, @x, ""; } my $total = sum(@fees); my $factorial = product([1..5]); my $joined = join(@out); 63

Slide 64

Slide 64 text

my $total = sum(@fees); my $factorial = product([1..5]); my $joined = join(@out); 64

Slide 65

Slide 65 text

my $total = [+] @fees; my $factorial = [*] 1..5; my $joined = [~] @out; 65

Slide 66

Slide 66 text

sub sum (@x) { | sub product (@x) { | sub join (@x) { my $a = 0; | my $a = 1; | my $a = ''; | | $a += $_ for @x;| $a *= $_ for @x; | $a ~= $_ for @x; | | return $a; | return $a; | return $a; } | } | } my $total = [+] @fees; my $factorial = [*] 1..5; my $joined = [~] @out; 66

Slide 67

Slide 67 text

“All these squares make a circle.” “All these squares make a circle.” “All these squares make a circle.”

Slide 68

Slide 68 text

–Mr. Popo, after dropping a gallon of LSD Dragonball Z [Abridged] “All these squares make a circle.” “All these squares make a circle.” “All these squares make a circle.”

Slide 69

Slide 69 text

my $total = @fees.sum; my $factorial = [*] 1..5; my $joined = @out.join; 69

Slide 70

Slide 70 text

my $total = @fees.sum; my $factorial = [*] 1..5; my $joined = @out.join; # There is a better way for factorial, though. 70

Slide 71

Slide 71 text

[op] @a @a[0] op @a[1] op @a[2] op @a[3] … 71

Slide 72

Slide 72 text

[op] @a @a[0] op @a[1] op @a[2] op @a[3] … [+] @a @a[0] + @a[1] + @a[2] + @a[3] … 72

Slide 73

Slide 73 text

my $o = [lt] @names; 73

Slide 74

Slide 74 text

my $o = [lt] @names; raku -e ' say [lt] ; say [lt] ; ' Output: True False @names[0] lt @names[1] lt @names[2] 74

Slide 75

Slide 75 text

raku -e ' my @nodes = "A".."E"; my $tree = [=>] @nodes; say $tree.raku; say $tree; say (A => B => C => D => "E");' :A(:B(:C(:D("E")))) A => B => C => D => E A => B => C => D => E Audrey uses it as "linked list consing", for you LISP users. https://github.com/Raku/roast/blob/master/S03- metaops/reduce.t#L141 75

Slide 76

Slide 76 text

A / \ B / \ C / \ D / \ E / \ 76

Slide 77

Slide 77 text

A / B / C / D / E 77

Slide 78

Slide 78 text

Produce Triangle Reduce

Slide 79

Slide 79 text

say [+] 1..6; # 21 79

Slide 80

Slide 80 text

say [+] 1..6; # 21 say [\+] 1..6; # (1 3 6 10 15 21) 80

Slide 81

Slide 81 text

say [\,] ; 81

Slide 82

Slide 82 text

Slide 83

Slide 83 text

say "6! = ", [*] 1..6; 6! = 720 # Auto-caching! constant @factorials = 1, |[\*] 1..*; 83

Slide 84

Slide 84 text

Z

Slide 85

Slide 85 text

Ways to do array keys @a.keys -> $i { ^@a -> $i { 0 .. @a.end -> $i { 0 ..^ @a.elems -> $i { 0 ..^ @a -> $i { 0 ..^ +@a -> $i { 0 .. @a - 1 -> $i { 0 .. +@a - 1 -> $i { 0 .. @a.elems - 1 -> $i { 85

Slide 86

Slide 86 text

Ways to do array keys @a.keys -> $i { ^@a -> $i { 0 .. @a.end -> $i { 0 ..^ @a.elems -> $i { 0 ..^ @a -> $i { 0 ..^ +@a -> $i { 0 .. @a - 1 -> $i { 0 .. +@a - 1 -> $i { 0 .. @a.elems - 1 -> $i { 86

Slide 87

Slide 87 text

for @names.keys -> $i { my ( $name, $addr, $postal ) = @names[$i], @addrs[$i], @posts[$i]; … } 87

Slide 88

Slide 88 text

for @names.keys -> $i { my ( $name, $addr, $postal ) = @names[$i], @addrs[$i], @posts[$i]; … } 88

Slide 89

Slide 89 text

for @names.keys -> $i { my ( $name, $addr, $postal ) = @names[$i], @addrs[$i], @posts[$i]; … } 89

Slide 90

Slide 90 text

for @names Z @addrs Z @posts -> ( $name, $addr, $postal ) { … } 90

Slide 91

Slide 91 text

for @names Z @addrs Z @posts -> ($name, $addr, $postal) { for ([Z] @names, @addrs, @posts) -> ($name, $addr, $postal) { for zip(@names, @addrs, @posts) -> ($name, $addr, $postal) { 91

Slide 92

Slide 92 text

my @nap = @names Z @addrs Z @post; ( name0, addr0, post0 ), ( name1, addr1, post1 ), … my @nap = [Z] @names, @addrs, @post; 92

Slide 93

Slide 93 text

.say for @names Z @addrs Z @post; .say for [Z] @names, @addrs, @post; .say for zip(@names, @addrs, @post); ( name0, addr0, post0 ), ( name1, addr1, post1 ), … 93

Slide 94

Slide 94 text

Zop Z+ Z- Zmax Zgt Zyoh

Slide 95

Slide 95 text

my @a = 6, 9, 11, 13; my @diffs = @a.keys.skip .map({ [-] @a[$_, $_-1] }); @a.skip == 9, 11, 13 @a == 6, 9, 11, 13 subtract 3 2 2 . 95

Slide 96

Slide 96 text

my @a = 6, 9, 11, 13; my @diffs = @a.skip Z- @a; @a.skip == 9, 11, 13 @a == 6, 9, 11, 13 subtract 3 2 2 . 96

Slide 97

Slide 97 text

[Z] transposition [Z] TRAP

Slide 98

Slide 98 text

[Z] Transposition my @matrix = (17,18,19), (27,28,29); .say for [Z] @matrix; (17 27) (18 28) (19 29) 98

Slide 99

Slide 99 text

[Z] Transposition my @matrix = (17,), (27,), (37,), (47,); .say for [Z] @matrix; (17 27 37 47) 99

Slide 100

Slide 100 text

[Z] Transposition my @matrix = ((17,27,37,47,),); .say for [Z] @matrix; (17 27 37 47) 100

Slide 101

Slide 101 text

X Cross-product

Slide 102

Slide 102 text

my @makes = ; my @years = 2021..2023; for @makes -> $make { for @years -> $year { say "$make $year ", (%sales{$make}{$year} // 0); } } 102

Slide 103

Slide 103 text

my @makes = ; my @years = 2021..2023; for @makes -> $make { for @years -> $year { say "$make $year ", (%sales{$make}{$year} // 0); } } 103

Slide 104

Slide 104 text

my @makes = ; my @years = 2021..2023; for @makes -> $make { - for @years -> $year { say "$make $year ", (%sales{$make}{$year} // 0); } } 104

Slide 105

Slide 105 text

my @makes = ; my @years = 2021..2023; for @makes -> $make { . for @years -> $year { say "$make $year ", (%sales{$make}{$year} // 0); } . } 105

Slide 106

Slide 106 text

my @makes = ; my @years = 2021..2023; for @makes -> $make { for @years -> $year { say "$make $year ", (%sales{$make}{$year} // 0); } } 106

Slide 107

Slide 107 text

my @makes = ; my @years = 2021..2023; for @makes X @years -> ($make, $year) { say "$make $year ", (%sales{$make}{$year} // 0); } 107

Slide 108

Slide 108 text

my @makes = ; my @years = 2021..2023; for @makes -> $make { for @years -> $year { say "$make $year ", (%sales{$make}{$year} // 0); } } 108

Slide 109

Slide 109 text

my @makes = ; my @years = 2021..2023; for @makes X @years -> ($make, $year) { say "$make $year ", (%sales{$make}{$year} // 0); } 109

Slide 110

Slide 110 text

my @makes = ; my @years = 2021..2023; for @makes X @years -> ($make, $year) { say "$make $year ", (%sales{$make}{$year} // 0); } 110

Slide 111

Slide 111 text

Rly? 111

Slide 112

Slide 112 text

# Integer $n is !== 0. say $n * 1; 112

Slide 113

Slide 113 text

my @ages-this-year = 6, 9, 11, 13; 113

Slide 114

Slide 114 text

my @ages-this-year = 6, 9, 11, 13; my @ages-next-year; 114

Slide 115

Slide 115 text

my @ages-this-year = 6, 9, 11, 13; my @ages-next-year; my @ages-next-next-year; 115

Slide 116

Slide 116 text

my @ages-this-year = 6, 9, 11, 13; my @ages-next-year; my @ages-next-next-year; my @nny; 116

Slide 117

Slide 117 text

my @ages-this-year = 6, 9, 11, 13; my @nny; 117

Slide 118

Slide 118 text

my @ages-this-year = 6, 9, 11, 13; my @nny = @ages-this-year; 118

Slide 119

Slide 119 text

my @ages-this-year = 6, 9, 11, 13; my @nny = @ages-this-year; for @nny <-> $age { $age += 2; } 119

Slide 120

Slide 120 text

my @ages-this-year = 6, 9, 11, 13; my @nny = @ages-this-year; $_ += 2 for @nny; 120

Slide 121

Slide 121 text

my @ages-this-year = 6, 9, 11, 13; my @[email protected]({$_+2}); 121

Slide 122

Slide 122 text

my @ages-this-year = 6, 9, 11, 13; my @[email protected]({$_+2}); my @nny = @ages-this-year X+ 2; 122

Slide 123

Slide 123 text

X Scaling

Slide 124

Slide 124 text

list Xop scalar scalar Xop list say @costs X* $inflation; say "Bob " X~ @last_names; 124

Slide 125

Slide 125 text

my @n = 2, 4, 42; say sqrt [+] @n X** 2; say ( @n X** 2 ).sum.sqrt; # 42.23742416388575 # 42.23742416388575 125

Slide 126

Slide 126 text

raku -e ' my @n = 2, 4, 42; say sqrt [+] @n X** 2; say ( @n X** 2 ).sum.sqrt; ' # 42.23742416388575 # 42.23742416388575 126

Slide 127

Slide 127 text

https://theweeklychallenge.org/blog/perl-weekly- challenge-274/#TASK1 # TWC Goat Latin # Rule 3: Add letter "a" to the end of first word in the sentence, "aa" to the second word, etc. constant @as = "a" Xx (1..*); # (a aa aaa aaaa …) return ( $s.words.map(&goat_word) Z~ @as ).join:" "; 127

Slide 128

Slide 128 text

Roller Coaster

Slide 129

Slide 129 text

Parallelism, Concurrency, and Asynchrony

Slide 130

Slide 130 text

130 • High-level: • Promises • Supplies • Channels • react/whenever • Low-level: • Threads • Schedulers • Locks • Semaphores https://docs.raku.org/language/concurrency

Slide 131

Slide 131 text

Parallelism, Concurrency, and Asynchrony

Slide 132

Slide 132 text

Parallelism, Concurrency, and Asynchrony

Slide 133

Slide 133 text

Parallel Execution

Slide 134

Slide 134 text

Parallel Execution

Slide 135

Slide 135 text

.hyper .hyper

Slide 136

Slide 136 text

No content

Slide 137

Slide 137 text

Hyper, via meta-operators

Slide 138

Slide 138 text

Hyper-operators

Slide 139

Slide 139 text

Hyper-operators op« »op «op« »op» «op» »op« op<< >>op <>op>> <> >>op<<

Slide 140

Slide 140 text

Magic direction repeat non-single group. Scaling Magic both ways == longest one is length? Yes! >>,<< 140

Slide 141

Slide 141 text

Goat Latin, revisited # (a aa aaa aaaa …) constant @as = "a" Xx (1..*); raku -e ' constant @as = "a" «x« (1..*); ' ===SORRY!=== Error while compiling -e An exception X::HyperOp::Infinite occurred while evaluating a constant: List on right side of hyperop of infix: is known to be infinite 141

Slide 142

Slide 142 text

Tear-off No side effects, no concurrency (shared resources), no asynchrony (not event-driven), order irrelevant 142

Slide 143

Slide 143 text

https://en.wikipedia.org/wiki/ ISBN#ISBN-13_check_digit_calculation x₁ + 3x₂ + x₃ + 3x₄ + x₅ + 3x₆ + x₇ + 3x₈ + x₉ + 3x₁₀ + x₁₁ + 3x₁₂ + x₁₃ ≡ 0 (mod 10) (@digits Z* <1 3 1 3 1 3 1 3 1 3 1 3>).sum (@digits Z* |( (1,3) xx * ) ).sum (@digits »*» (1,3) ).sum 143

Slide 144

Slide 144 text

Nodality

Slide 145

Slide 145 text

raku -e 'my @a = [ [11,12], [13,14], [15,16] ], [ [21,22], [23,24], [25,26] ]; my @b = @a».rotate; my @c = @a »+» 1; say @b; say @c;' [ ( [13 14] [15 16] [11 12] ) ( [23 24] [25 26] [21 22] ) ] .rotate is nodal, so hyper only goes down 1 level [ [ [12 13] [14 15] [16 17] ] [ [22 23] [24 25] [26 27] ] ] `+` is not nodal, so every element incremented 145

Slide 146

Slide 146 text

https://docs.raku.org/language/typesystem#trait_is_nodal trait is nodal Marks a List method to indicate to hyperoperator to not descend into inner Iterables to call this method. This trait generally isn't something end users would be using, unless they're subclassing or augmenting core List type. In order to demonstrate the difference consider the following examples, the first using a method (elems) that is nodal and the second using a method (Int) which is not nodal. say ((1.0, "2", 3e0), [^4], '5')».elems; # OUTPUT: «(3, 4, 1) ␤ » say ((1.0, "2", 3e0), [^4], '5')».Int # OUTPUT: «((1 2 3) [0 1 2 3] 5) ␤ » 146

Slide 147

Slide 147 text

use nqp; for Str, Int, List, Array, Seq -> $type { my $b = $type.^methods .map({ nqp::can($_,"nodal") }).Bag; say $type.^name.fmt("%-7s: "), $b.raku; } Str : (0=>79).Bag Int : (0=>86).Bag List : (0=>37, 1=>36).Bag Array : (0=>63, 1=>51).Bag Seq : (0=>25, 1=>17).Bag 147

Slide 148

Slide 148 text

use nqp; for Str, Int, List, Array, Seq -> $type { my $b = $type.^methods .map({ nqp::can($_,"nodal") }).Bag; say $type.^name.fmt("%-7s: "), $b.raku; } Str : ( 0=>79 ).Bag Int : ( 0=>86 ).Bag List : ( 0=>37, 1=>36 ).Bag Array : ( 0=>63, 1=>51 ).Bag Seq : ( 0=>25, 1=>17 ).Bag 148

Slide 149

Slide 149 text

use nqp; say nqp::can( &prefix:<++>, "nodal" ); # 0 say nqp::can( List.^lookup("pairs"), "nodal" ); # 1 149

Slide 150

Slide 150 text

say &prefix:<++>.can("nodal"); # () say List.^lookup("pairs").can("nodal"); # (nodal) 150

Slide 151

Slide 151 text

raku -e ' use nqp; say nqp::can($_,"nodal"), " ", .name for List.^methods; ' | sort # Output on next 2 pages, grouped as `0` or `1`. 151

Slide 152

Slide 152 text

0 == not Nodal ACCEPTS ASSIGN-POS BIND-POS BUILDALL Bool Capture FLATTENABLE_HASH FLATTENABLE_LIST Int Numeric STORE Str chrs eager flat fmt from from-iterator from-slurpy from-slurpy-flat from-slurpy-onearg gist head hyper is-lazy item iterator lazy lazy-if new of race raku reification-target sink tail to 152

Slide 153

Slide 153 text

1 == Nodal AT-POS Array Bag BagHash EXISTS-POS List Mix MixHash Set SetHash Slip Supply antipairs append combinations elems end invert join keys kv list pairs permutations pick pop prepend push reverse roll rotate shift sort sum unshift values 153

Slide 154

Slide 154 text

https://oeis.org/A104101 my @L = 4,8,15,16,23,42 ; my @L = <4 8 15 16 23 42>; my @L = +«<4 8 15 16 23 42>; say .WHAT for @L.map; ((IntStr) (IntStr) (IntStr) (IntStr) (IntStr) (IntStr)) ((Int) (Int) (Int) (Int) (Int) (Int)) 154

Slide 155

Slide 155 text

https://oeis.org/A104101 my @L = 4,8,15,16,23,42 ; my @L = <4 8 15 16 23 42>; my @L = +«<4 8 15 16 23 42>; say .WHAT for @L.map; ((IntStr) (IntStr) (IntStr) (IntStr) (IntStr) (IntStr)) ((Int) (Int) (Int) (Int) (Int) (Int)) 155

Slide 156

Slide 156 text

https://oeis.org/A104101 say @L.map({ .WHAT }); say @L.map:{ .WHAT }; say @L.map: *.WHAT; say @L».WHAT; 156

Slide 157

Slide 157 text

Talk not Class

Slide 158

Slide 158 text

Q & A ? (vs. Bonus Topic)

Slide 159

Slide 159 text

Thank you for coming!

Slide 160

Slide 160 text

Copyright Information: Images • Camelia • © 2009 by Larry Wall
 http://github.com/perl6/mu/raw/master/misc/camelia.txt • Periodic Table of the Operators • © 2004, 2009 by Mark Lentczner
 https://www.ozonehouse.com/mark/periodic/ • Beer Barrel Keg Cask • by Steve Buissinne ; Free for use under the Pixabay Content License
 https://pixabay.com/photos/beer-barrel-keg-cask-oak-barrel-956322/
 https://pixabay.com/users/stevepb-282134/
 https://pixabay.com/service/terms/

Slide 161

Slide 161 text

LICENSE • © 2024 Bruce Gray 
 This work is openly licensed under CC BY 4.0.
 https://creativecommons.org/licenses/by/4.0/