Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Perl 6 in context

lichtkind
September 05, 2015

Perl 6 in context

A longer talk about the many operators of Perl 6 with a deeper introduction what are ops good for and why Perl is called an operator oriented language

lichtkind

September 05, 2015

Transcript

287 slides
  1. Bool Context ? ! ?^ ?| ?& ^ | &

    // ^^ || && ff fff ?? !!
  2. Grey is Logic ? ! ?^ ?| ?& ^ |

    & // ^^ || && ff fff ?? !!
  3. Is it so ? my $var = e; say so($var);

    True Bool::True v String Context
  4. Is it not so ? my $var = e; say

    not $var; False Bool::False v String Cont.
  5. Low Precedence my $var = 45; say so $var +

    1; True 46 v Bool Kontext = True
  6. Bool Context my $var = 45; say 1 if $var

    + 1; 1 46 v Bool Context = True
  7. Bool Context my $var = 45; say 1 if $var

    + 1; 1 If unless while until
  8. That was easy ! ? ! ?^ ?| ?& ^

    | & // ^^ || && ff fff ?? !!
  9. You get a sense ? ! ?^ ?| ?& ^

    | & // ^^ || && ff fff ?? !!
  10. Short Overview 0 | 1 | 3 = any(0,1,3); 0

    & 1 & 3 = all(0,1,3); 0 ^ 1 ^ 3 = one(0,1,3);
  11. Junctions ! if $val == 0 | 1 | 3

    { ... any(False, True, False).to_bool
  12. It Gets Clearer ? ! ?^ ?| ?& ^ |

    & // ^^ || && ff fff ?? !!
  13. Was .. | … in $ contxt while … {

    run() if begin() ff end(); run() if begin() fff end(); }
  14. Skoro u Cile ? ! ?^ ?| ?& ^ |

    & // ^^ || && ff fff ?? !!
  15. All Clear Now ? ? ! ?^ ?| ?& ^

    | & // ^^ || && ff fff ?? !!
  16. xx Operator say 'eins zwo eins zwo'; say q:words(eins zwo)

    xx 2; say q:w(eins zwo) xx 2; say qw(eins zwo) xx 2;
  17. xx Operator say 'eins zwo eins zwo'; say q:words(eins zwo)

    xx 2; say q:w(eins zwo) xx 2; say qw(eins zwo) xx 2; say <eins zwo> xx 2;
  18. Its pairs in real: say <eins zwo> X <dan rabauke>;

    ('eins','dan'),('eins','rabauke'), ('zwo','dan'),('zwo','rabauke')
  19. Schwartz Transform my @output = map { $_->[0] } sort

    { $a->[1] cmp $b->[1] } map { [$_,expensive_func($_)] } @input;
  20. Pipe Operator my @output <== map { $_[0] } <==

    sort { $^a[1] cmp $^b[1] } <== map { [$_, expensive_fun($_)] } <== @input;
  21. Other Direction @input ==> map { [$_,expensive_fun($_)] } ==> sort

    { $^a[1] cmp $^b[1] } ==> map { $_[0] } ==> my @output;
  22. Append Mode my @output <<== map { $_[0] } <<==

    sort { $^a[1] cmp $^b[1] } <<== map { [$_,expensive_fun($_)] } <<== @input;
  23. all get older @age == 18, 22, 35; @age =

    @age >>+>> 1; @age == 19, 23, 36;
  24. only one gets older @age == 18, 22, 35; @age

    = @age <<+<< 1; @age == 19;

More Decks by lichtkind

Other Decks in Programming