Perl 6 Data Structures
Herbert Breunung
CPAN: lichtkind
Kephra 0.4.3.32
Kephra Logo
Als Hieroglyphe
Mansfelder Land
Mansfelder Land
Egypt aka Khem
Ein (K|C)amel
Noch ein Kamel?
Camelia
Camel ia
 
Schlaraffenland
Heiliger Gral
Schönheit Und Struktur
Datenstrukturen
 
@rrays Und %ashes
Auch $calare
Perl 5 <ul>@cities   = ( 'roma' ,   'milano' ,   'torino' ); </ul>
Perl 5 & 6 <ul>@cities   = ( 'roma' ,   'milano' ,   'torino' ); </ul>
Perl 5 <ul>@cities   = qw( roma   milano   torino ); </ul>
Perl 6 <ul>@cities   = qw( roma   milano   torino ); @cities   = < roma   milano   torino >; </ul>
Mit Interpolation Wie “ “ <ul>@cities   = qw( roma   milano   torino ); @cities   = < roma   milano   torino >; @cities   ...
Perl 5 & 6 <ul>@cities   = ( 'roma' ,   'milano' ,   'torino' ); </ul>
P5 & P6 <ul>@cities   = ( 'roma' ,   'milano' ,   'torino' ); @cities   =  'roma' ,   'milano' ,   'torino' ; </ul>
Klammern Gruppieren ! <ul>@cities   = ( 'roma' ,   'milano' ,   'torino' ); @cities   =  'roma' ,   'milano' ,   'torino' ...
Itemkontext <ul>$cities   = ( 'roma' ,   'milano' ,   'torino' ); $cities   =  'roma' ,   'milano' ,   'torino' ; </ul>
Itemkontext <ul># Parcel() $cities   = ( 'roma' ,   'milano' ,   'torino' ); # Str() $cities   =  'roma' ,   'milano' ,   ...
Was Ist Str ? <ul># Parcel() $cities   = ( 'roma' ,   'milano' ,   'torino' ); # Str() - 'roma' ist ein String $cities   =...
Nur Der Erste Wert <ul># Parcel() $cities   = ( 'roma' ,   'milano' ,   'turino' ); # $a, $b, $c = 1, 2, 3; $cities   =  '...
Was Ist Ein Parcel ? <ul># Parcel – Sequenz von Items $cities   = ( 'roma' ,   'milano' ,   'torino' ); # Str() $cities   ...
() Erinnert An Was? <ul># Parcel – wie in function(1,2,3); $cities   = ( 'roma' ,   'milano' ,   'torino' ); # Str() $citi...
Parcel <ul># hat pos. und benannte Args $cities   = ( 'roma' ,   'milano' ,   'torino' ); # Str() $cities   =  'roma' ,   ...
Kontainertypen <ul># Array() $cities   = [ 'roma' ,   'milano' ,   'torino' ]; # Parcel() $cities   = ( 'roma' ,   'milano...
Array() ne List() ne Parcel() <ul># List() $cities  =  @( 'roma' ,   'milano' ,   'torino' ); # Parcel() $cities   = ( 'ro...
Nur Eine Liste <ul># List() $cities  = list ( 'roma' ,   'milano' ,   'torino' ); # Parcel() $cities   = ( 'roma' ,   'mil...
Pos. Param. Als Liste <ul># List() $cities  = list ( 'roma' ,   'milano' ,   'torino' ); # List() $cities   = ||( 'roma' ,...
Array Objekt <ul>$cities   = [ 'roma' ,   'milano' ,   'torino' ]; @cities   =  'roma' ,   'milano' ,   'torino' ; say   $...
Nummer An Elementen <ul>say   length   @cities ;  # 3 say elems  @cities ;  #  3 # kein length </ul>
„ elems“ Ist Methode <ul>say   length   @cities ;  # 3 say  @cities . elems ;  # 3 </ul>
An Jedem Arrayobjekt <ul>say   scalar  @$cities ;  # 3 say  $cities . elems ;  #  3 </ul>
Inhalt Vom Skalar <ul>say   “@$cities“ ;  # roma ... say  $cities ;  #  roma ... </ul>
Auch Im Skalarkontext <ul>say   “@cities“ ;  # roma ... say  $( @cities ) ;  #  roma ... </ul>
Ich Meinte Itemkontext <ul>say   “@cities“ ;  # roma ... say  item( @cities ) ;  #  roma ... </ul>
Numerischer Kontext <ul>say   scalar   @cities ;  # 3 say  +   @cities ;  #  3 </ul>
Numerischer Kontext <ul>say   scalar   @$cities ;  # 3 say  +   $cities ;  #  3 </ul>
Boolkontext <ul>say   values   @cities ;  # romami... say  ?   @cities ;  #  Bool::True </ul>
Stringkontext <ul>say   “@cities“ ;  # roma milano say  ~   @cities ;  #  roma milano ... </ul>
. Wurde ~ <ul>say   “@cities“ ;  # roma milano say  “...“   ~   @cities ;  # ...roma mila..   </ul>
Gehts Auch in P6 ? <ul>say   “ @cities“ ; # roma milano torino say  “@cities“ ; #  roma milano torino? </ul>
Nicht Ganz <ul>say   “@cities“ ;  # roma milano ... say  “@cities“ ;  #  @cities </ul>
Füge „[]“ An <ul>say   “@cities“ ;  # roma milano say  “@cities[]“ ; #  roma milano ... </ul>
Das War Kein Spezialfall <ul>say   “@cities“ ;  # roma milano say  @cities [] ;   #  roma milano ... </ul>
Perl 5 & 6 <ul>say  @cities ;  # romamilanotorino say  @cities ;  # roma milano torino </ul>
Tiefer Als Listen
STD Perl 5 <ul>use   Data::Dumper ; say   Dumper ( @cities ); </ul>
$VAR1 = 2;  $VAR2 = 3; $VAR3 = 4; $VAR4 = 5; $VAR5 = 6; $VAR6 = 7; $VAR7 = 7; $VAR8 = 2; $VAR9 = 5; $VAR10 = [ 'a', 'b', '...
Er Hats Repariert <ul>use   YAML ;  #  Data::Dumper  sucks say   Dump  @cities ;  </ul>
--- - 2 - 3 - 4 - 5 - 6 - 7 - 7 - 2 - 5 - - a - b - c [2, 3, 4, 5, 6, 7, 7, 2, 5, [&quot;a&quot;, &quot;b&quot;, &quot;c&q...
--- - 2 - 3 - 4 - 5 - 6 - 7 - 7 - 2 - 5 - - a - b - c [2, 3, 4, 5, 6, 7, 7, 2, 5, [&quot;a&quot;, &quot;b&quot;, &quot;c&q...
Perl 6 <ul>say  @cities . perl ; </ul>
Mit eval Rückwandelbar <ul># in jeder Tiefe: say  @cities . perl ; $ [&quot;roma&quot;, &quot;milano&quot;, &quot;torino&q...
Perl 5 <ul>say  $cities [ 2 ];  # torino </ul>
Perl 6 <ul>say  $cities [ 2 ];  # torino say  @cities [ 2 ];  # torino </ul>
Array Als Item <ul>say  $cities [ 2 ];  # in Perl 6 auch say  @cities [ 2 ];  # torino </ul>
Der Selbe Kontainertyp <ul>$cities   = [ 'roma' ,   'milano' ,   'torino' ]; say  $cities [ 2 ];  # $cities.WHAT say  @cit...
Arrayobjekt <ul>say  $cities [ 2 ];  # Array() say  @cities [ 2 ];  # Array() </ul>
Say Ist Eine Methode <ul>say  $cities [ 2 ];  # torino @cities [ 2 ]. say ;  # dito </ul>
[ ] Auch (Wie Jeder Op) <ul>say  $cities .[ 2 ];  #  2 ist parameter @cities .[ 2 ]. say ;  # dito </ul>
2 ist Letzter Index <ul>say  $cities [ 2 ];  # torino say  @cities [ 2 ];  # dito </ul>
Perl 5 <ul>say  $cities [ -1 ];  # torino say  @cities [ 2 ];  # dito </ul>
Perl 6 <ul>say  $cities [ -1 ];  # torino say  @cities [* -1 ];   # dito </ul>
Whatever * <ul>say  @cities [*- 1 ];   # torino </ul>
Whatever * <ul>say  @cities [*- 1 ];   # torino # parameter „*-1“ ist eine closure </ul>
Whatever * <ul>say  @cities [*- 1 ];   # torino # parameter „*-1“ ist eine closure # * ist parameter an diese closure </ul>
Whatever * <ul>say  @cities [*- 1 ];   # turino # parameter „*-1“ ist eine closure # * ist parameter an diese closure # * ...
Whatever * <ul>say  @cities [*- 1 ];   # torino say  @cities [* /  2 ]; # milano </ul>
Whatever * <ul>say   “@cities“ ;   #  roma milano torino say  @cities [*];  #   roma milano torino </ul>
Whatever * <ul>say   “@cities“ ;   #  roma milano torino say  @cities [];  #   roma milano torino # default param ist * </ul>
LoL <ul>say  @cities [ 1 ][ 1 ]; </ul>
List Of List <ul>@cities  = [< roma .. >], [< berlin .. >]; say  @cities [ 1 ][ 1 ]; say  $cities [ 1 ; 1 ]; </ul>
Ein Spiel
Zähl die Schlümpfe
Zähle <ul>Wie viele Elemente hat diese Liste? </ul>
Count
Runde 1
Wie Viele Elemente ? <ul>my  @number  =  1 ,  2 ,  3 ,  4 ; </ul>
Wie Viele Elemente ? <ul>my  @number  =  1 ,  2 ,  3 ,  4 ;  # 4 my  @number  = ( 1 ,  2 ,  3 ,  4 ); </ul>
Wie Viele Elemente ? <ul>my  @number  =  1 ,  2 ,  3 ,  4 ;  # 4 my  @number  = ( 1 ,  2 ,  3 ,  4 );  # 4 my  @number  = ...
Wie Viele Elemente ? <ul>my  @number  =  1 ,  2 ,  3 ,  4 ;  # 4 my  @number  = ( 1 ,  2 ,  3 ,  4 );  # 4 my  @number  = ...
Wie Viele Elemente ? <ul>my  @number  =  1 ,  2 ,  3 ,  4 ;  # 4 my  @number  = ( 1 ,  2 ,  3 ,  4 );  # 4 my  @number  = ...
Wie Viele Elemente ? <ul>my  @number  =  1 ,  2 ,  3 ,  4 ;  # 4 my  @number  = ( 1 ,  2 ,  3 ,  4 );  # 4 my  @number  = ...
Wie Viele Elemente ? <ul>my  @number  =  1 ,  2 ,  3 ,  4 ;  # 4 my  @number  = ( 1 ,  2 ,  3 ,  4 );  # 4 my  @number  = ...
Runde 2
Wie Viele Elemente ? <ul>my  $number  =  1 ,  2 ,  3 ,  4 ;  </ul>
Wie Viele Elemente ? <ul>my  $number  =  1 ,  2 ,  3 ,  4 ;  # 1 my  $number  = ( 1 ,  2 ,  3 ,  4 );  </ul>
Wie Viele Elemente ? <ul>my  $number  =  1 ,  2 ,  3 ,  4 ;  # 1 my  $number  = ( 1 ,  2 ,  3 ,  4 );  # 4 my  $number  = ...
Wie Viele Elemente ? <ul>my  $number  =  1 ,  2 ,  3 ,  4 ;  # 1 my  $number  = ( 1 ,  2 ,  3 ,  4 );  # 4 my  $number  = ...
Wie Viele Elemente ? <ul>my  $number  =  1 ,  2 ,  3 ,  4 ;  # 1 my  $number  = ( 1 ,  2 ,  3 ,  4 );  # 4 my  $number  = ...
Wie Viele Elemente ? <ul>my  $number  =  1 ,  2 ,  3 ,  4 ;  # 1 my  $number  = ( 1 ,  2 ,  3 ,  4 );  # 4 my  $number  = ...
Wie Viele Elemente ? <ul>my  $number  =  1 ,  2 ,  3 ,  4 ;  # 1 my  $number  = ( 1 ,  2 ,  3 ,  4 );  # 4 my  $number  = ...
Runde 3
Wie Viele Elemente ? <ul>my  $pd   =   my  @pd  = ( 3 ,  1 ,  4 ,  1 ); </ul>
Wie Viele Elemente ? <ul>my  $pd   =   my  @pd  = ( 3 ,  1 ,  4 ,  1 ); @number  =  1 ,   @pd ,  4 ; </ul>
Wie Viele Elemente ? <ul>my  $pd   =   my  @pd  = ( 3 ,  1 ,  4 ,  1 ); @number  =  1 ,  @pd ,  4 ;  # 6 @number  =  1 ,  ...
Wie Viele Elemente ? <ul>my  $pd   =   my  @pd  = ( 3 ,  1 ,  4 ,  1 ); @number  =  1 ,  @pd ,  4 ;  # 6 @number  =  1 ,  ...
item & list == Konextops <ul>my  $pd   =   my  @pd  = ( 3 ,  1 ,  4 ,  1 ); @number  =  1 ,  @pd ,  4 ;  # 6 @number  =  1...
Wie Viele Elemente ? <ul>my  $pd   =   my  @pd  = ( 3 ,  1 ,  4 ,  1 ); @number  =  1 ,  @pd ,  4 ;  # 6 @number  =  1 ,  ...
Nil != undef <ul>my  $pd   =   my  @pd  = ( 3 ,  1 ,  4 ,  1 ); @number  =  1 ,  @pd ,  4 ;  # 6 @number  =  1 ,  $pd ,  4...
And The Winner Is ...
Perl 5 <ul>@digits   = (  4  ) x  5 ;  # (4,4,4,4,4) </ul>
Perl 6 <ul>@digits   = (  4  ) x  5 ;  # (4,4,4,4,4) @digits   = (  4  ) xx  5 ;  # 4,4,4,4,4 </ul>
Verfielfacht Listen <ul>@digits   = (  4  ) x  5 ;  # (4,4,4,4,4) @digits   =  4  xx  5 ;  # 4,4,4,4,4 </ul>
Verfielfacht Strings <ul>@digits   =  4  x  5 ;  # '44444' @digits   =  4  x  5 ;  # '44444' </ul>
Verfielfacht Strings <ul>@digits   =  4  x  5 ;  # '44444' @digits   = ( 4 ) x  5 ;  # '44444' </ul>
Verfielfacht Strings <ul>@digits   =  '1 2'   x  3 ;  # '1 21 21 2' @digits   = ( 1 , 2 ) x  3 ;  # '1 21 21 2' </ul>
Verfielfacht Listen <ul>@digits   = ( 1 , 2 ) x  3 ;  #  1,2,1,2,1,2 @digits   = ( 1 , 2 ) xx  3 ;  #  1,2,1,2,1,2 </ul>
Perl 5 <ul>@digits   = (  0  ..  9  );  # Bereichsop </ul>
Perl 5 & 6 <ul>@digits   = (  0  ..  9  ); </ul>
Perl 6 <ul>@digits   =  0  ..  9 ; </ul>
Perl 6 <ul>@digits   = ^  10 ;  # 0 .. 9 </ul>
0 Ist Gegeben <ul>@digits   =  0  ..^  10 ;  # 0 .. 9 (@) </ul>
^ Schließt Schranke Aus <ul>@digits   =  -1  ^..^  10 ;  # 0 .. 9 </ul>
Sequence - Operator <ul>@digits   =  0  ...  9 ;  </ul>
Linear <ul>@digits   =  0  ...  9 ;  # 0 .. 9 </ul>
Arithmetisch <ul>@digits   =  0  ...  9 ;  # 0 .. 9 @odd   =  1 , 3  …  9 ;  # 1,3,5,7,9 </ul>
Geometrisch <ul>@digits   =  0  ...  9 ;  # 0 .. 9 @odd   =  1 , 3  …  9 ;  # 1,3,5,7,9 @bin   =  1 , 2 , 4  …  1024 ; #.....
Fibonacci <ul>@digits   =  0  ...  9 ;  # 0 .. 9 @odd   =  1 , 3  …  9 ;  # 1,3,5,7,9 @bin   =  1 , 2 , 4  …  1024 ; #..,8...
Prüf Das Limit <ul>@odd   =  1 , 3  …  10 ;  # 1,3,.. * </ul>
Unendliche Liste <ul>@odd   =  1 , 3  …  10 ;  # 1,3,.. * @number   =  0  .. *;  # 0 .. Inf </ul>
Bestimmte Elemente <ul>@odd   =  1 , 3  …  10 ;  # 1,3,.. * @number   =  0  .. *;  # 0 .. Inf say   @odd [ 1 ];  # 3 say  ...
Alle Elemente <ul>@odd   =  1 , 3  …  10 ;  # 1,3,.. * @number   =  0  .. *;  # 0 .. Inf say   @odd [*];  # warten ... say...
Anzahl Der Elemente <ul>@odd   =  1 , 3  …  10 ;  # 1,3,.. * @number   =  0  .. *;  # 0 .. Inf say   +  @odd ;  # warten ....
Was ist geschehen? <ul>$number   =  0  .. *;  # 0 .. Inf say   $number . WHAT ;   # Range() </ul>
Ausgabe ? <ul>$number   =  0  .. *;  # 0 .. Inf say   $number ;  # ? </ul>
Erstes Element <ul>$number   =  0  .. *;  # 0 .. Inf say   $number ;  # 0 </ul>
Unendliche Liste <ul>$number   =  0  .. *;  # 0 .. Inf say   @( $number );  # digits ... </ul>
Array <ul>@number   =  0  .. *;  # 0 .. Inf say   @number [ 5 ]; </ul>
Bei Bedarf Erzeugt <ul>@number   =  0  .. *;  # 0 .. Inf say   @number [ 5 ];  #   @number.reify(5) </ul>
Interne Repräsentation <ul>@number   =  0  .. *;  # 0 .. Inf say   @number . reify ( 5 ). perl ; # (0, 1, 2, 3, 4, 5, 6..*...
Ihr Kennt Diese <ul>shift  unshift push  pop  splice  reverse map  grep  </ul>
Perl 5 <ul>%opera   = ( 'verdi'  =>  'Aida' , 'puccini'  =>  'Turandot' , 'rossini' =>  'Il barbiere' , ); </ul>
Perl 6 <ul>%opera   = ( 'verdi'  =>  'Aida' , 'puccini'  =>  'Turandot' , 'rossini' =>  'Il barbiere' , ); </ul>
Kein Gruppieren Nötig <ul>%opera   = 'verdi'  =>  'Aida' , 'puccini'  =>  'Turandot' , 'rossini' =>  'Il barbiere' , ; </ul>
Immer Noch Ein Hash <ul>%opera   =  'verdi'  =>  'Aida' , 'puccini'  =>  'Turandot' , 'rossini' =>  'Il barbiere' , ; %ope...
Neuer Paar-Syntax <ul>%opera   = : verdi ( 'Aida' ), : puccini ( 'Turandot' ), : rossini ( 'Il barbiere' ), ; %opera . WHA...
Mit Autoquoting <ul>%opera   =  : verdi < Aida >, : puccini < Turandot >, : rossini < Il barbiere >, ; %opera . WHAT   eq ...
Item - Kontext <ul>$opera   =  : verdi < Aida >, : puccini < Turandot >, : rossini < Il barbiere >, ; $opera . WHAT   eq  ...
Gruppiert <ul>$opera   =  ( : verdi < Aida >, : puccini < Turandot >, : rossini < Il barbiere >, ); %opera . WHAT   eq   '...
Packet Kennt Pos. <ul>$opera   =  ( : verdi < Aida >, : puccini < Turandot >, : rossini < Il barbiere >, ); 0 verdi Aida 1...
Hashkontext - Op <ul>$opera   =  %( : verdi < Aida >, : puccini < Turandot >, : rossini < Il barbiere >, ); %opera . WHAT ...
Hashkontext - Op <ul>$opera   =  hash( : verdi < Aida >, : puccini < Turandot >, : rossini < Il barbiere >, ); %opera . WH...
Hash-Generator-Op <ul>$opera   =  { : verdi < Aida >, : puccini < Turandot >, : rossini < Il barbiere >, }; %opera . WHAT ...
Hash - Generator - Op <ul>%opera   =  { : verdi < Aida >, : puccini < Turandot >, : rossini < Il barbiere >, }; %opera . W...
Invariante Sigils <ul>%opera { 'rossini' };  # Il barbiere </ul>
Invariante Sigils <ul>%opera .{ 'rossini' };  # alias .at_key() </ul>
Erinnern An qw() ? <ul>%opera { 'rossini' };  # Il barbiere %opera < rossini >;  </ul>
Mit Interpolation <ul>%opera { 'rossini' };  # Il barbiere %opera < rossini >;  %opera << $autore >>;  </ul>
2 Opern Auf Einmal <ul>%opera { 'rossini' ,  'puccini' }; %opera < rossini puccini >;  %opera << @autore >>;  </ul>
Sind Auch Hashes <ul>$opera { 'rossini' ,  'puccini' }; $opera < rossini puccini >;  $opera << @autore >>;  </ul>
Auch Mit Parcel() <ul>#   oder Capture() $opera { 'rossini' ,  'puccini' }; $opera < rossini puccini >;  $opera << @autore...
Hash Methoden <ul>%opera . keys ;  # verdi puccini ro... %opera . values ;  # aida turandot ... %opera . kv ;  # verdi aid...
Haben Arrays Auch <ul>@cities . keys ;  # 0 1 2 @cities . values ;  # roma milano ... @cities . kv ;  # 0 roma 1 milano 2 ...
Auch Paare <ul>$opera . key ;  # rossini $opera . value ;  # Il barbiere $opera ;  #  </ul>
Mehr Hash Methoden <ul>%opera . pairs ;  # list of pair obj. %opera . exists ;  # Bool %opera . delete ;  # 1 | 0 </ul>
Mehr Hash Methoden <ul>%opera . pairs ;  # list of pair obj. %opera . exists ;  # one at a time %opera . delete ;  # one a...
Hash Im Kontext <ul>?  %opera ;  # bool Kontext +  %opera ;  # num Kontext ~  %opera ;  # string Kontext </ul>
Hash Im Kontext <ul>?  %opera ;  # Bool::True +  %opera ;  # 3 ~  %opera ;  # rossini Il barbiere </ul>
Value Im Kontext <ul>?  %opera ;  # Bool::True +  %opera ;  # 3 ~  %opera ;  # rossini Il barbiere </ul>
Neue Hashmethoden <ul>say  %opera . invert ; Aida  verdi Turandot  puccini Il barbiere  rossini </ul>
Hash Erzeuger <ul>my  %h  =  @cities . classify  ( {  uc substr (  $_ ,   0 ,   1  ) } ); say   %h ; $ R  roma M  milano T...
Hash Erzeuger <ul>@cities . categorize ({  catsub ( $_   ) }); say   %h . perl ; </ul>
Hash Erzeuger <ul>@cities . categorize ({  water ( $_   ) }); say   %h . perl ; {&quot;mare&quot; => [&quot;roma&quot;], &...
==> <ul>Pipes </ul>
Schwartz. Transform <ul>@results   =  map  {…},  sort  {…},  map  {...},  @input ; </ul>
Schwartz. Transform <ul>@results   =  map  {…},  sort  {…},  map  {...},  @input ; @results   =  map  {…} <==  sort  {…} <...
Schwartz. Transform <ul>@results   =  map  {…},  sort  {…},  map  {...},  @input ; @results   <==  map  {…} <==  sort  {…}...
Schwartz. Transform <ul>@results   =  map  {…},  sort  {…},  map  {...},  @input ; @input   ==>  map  {…} ==>  sort  {…} =...
Metaops
Metaops <ul>= ! R </ul>
Metaops <ul>>> [ ] [ ] X Z S </ul>
Metaops <ul>>> [ ] [ ] X Z S </ul>
Hyperoperator <ul>>> </ul>
Hyperoperator <ul>>> .hyper() </ul>
Simple Example <ul>( 1 .. 5 ) >>++ </ul>
That Works <ul>@number >>++ </ul>
Result <ul>@number >>++ 2 ,  3 ,  4 ,  5 ,  6 </ul>
More Complicated <ul>( 1 .. 5 ) >>+>>   1 </ul>
Check Your Spaces <ul>(1..5) _ >>+>> _ 1 </ul>
Same Result <ul>( 1 .. 5 ) >>+>>   1 2 ,  3 ,  4 ,  5 ,  6 </ul>
Reverse Hyper <ul>( 1 .. 5 ) <<+<<   1 </ul>
Right Side Rules <ul>( 1 .. 5 ) <<+<<   1 2 </ul>
Both Rule ? <ul>( 1 .. 5 ) >>+<<   1 </ul>
Yes Both! <ul>( 1 .. 5 ) >>+<<   1 Runtime Error !!! </ul>
Preserves LoL ? <ul>( 1 .. 5 , [ 6 .. 9 ]) >>+>>   1 </ul>
Preserves LoL ! <ul>( 1 .. 5 , [ 6 .. 9 ]) >>+>>   1 2 ,  3 ,  4 ,  5 ,  6 ,   [ 7 ,  8 ,  9 , 10 ] </ul>
On 2 Sides ? <ul>( 1 .. 5 , [ 6 .. 9 ]) >>+<<   ( 0 .. 4 , [ 1 .. 4 ]) </ul>
On 2 Sides ! <ul>( 1 .. 5 , [ 6 .. 9 ]) >>+<<   ( 0 .. 4 , [ 1 .. 4 ]) ( 1 ,  3 ,  5 ,  7 ,  9 , [ 7 ,  9 ,  11 ,  13 ]) <...
How About This? <ul>( 1 .. 5 , [ 6 .. 9 ]) >>+<<   ( 0 .. 4 , [ 1 .. 5 ]) </ul>
Checks Lengths <ul>( 1 .. 5 , [ 6 .. 9 ]) >>+<<   ( 0 .. 4 , [ 1 .. 5 ]) Runtime Error </ul>
Reduce <ul>[ ] .reduce </ul>
Do The Gauss <ul>[+] ( 1 .. 100 ) </ul>
Do The Gauss <ul>[+] ( 1 .. 100 ) 1  +  2  +  3  +  4  +  5  +  6  +  7  +  8  + ... </ul>
100+1 * 50 <ul>[+] ( 1 .. 100 ) 5050 </ul>
Chained Comparsion <ul>[<] ( 1 .. 100 ) </ul>
Chained Comparsion <ul>[<] ( 1 .. 100 ) 1  <  2  <  3  <  4  <  5  <  6  <  7  <  8  < ... </ul>
Chained Comparsion <ul>[<] ( 1 .. 100 ) Bool::True </ul>
Junction <ul>all ( 1 .. 100 ) >  0 </ul>
Junction <ul>all ( 1 .. 100 ) 1  |  2  |  3  |  4  |  5  |  6  |  7  |  8  |  9  | ... </ul>
Junction <ul>all ( 1 .. 100 ) >  0 ( True ,   True ,  True , True , ... </ul>
Bool Context <ul>? all ( 1 .. 100 ) >  0 True </ul>
Bool Context <ul>? all ( 1 .. 100 ) >  1 False </ul>
Metaops <ul>>> [ ] [ ] X Z S </ul>
Triangle <ul>[ ] triangle() </ul>
Back To Gauss <ul>[+] ( 1 .. 100 ) </ul>
Returns A List <ul>[+] ( 1 .. 100 ) ((((( 1 )   +  2  )   +  3 )   +  4 )   +  5 )   +  6 ) + ... </ul>
Returns A List <ul>[+] ( 1 .. 100 ) ( 1 ,  3 ,  6 ,  10 ,  15 ,  21 ,  28 , ... </ul>
Metaops <ul>>> [ ] [ ] X Z S </ul>
Cross <ul>.crosswith X </ul>
Cross <ul>( 1 ,  2 ) X ( 1 ,  2 ) 11 ,  12 ,  21 ,  22 </ul>
Cross With Power <ul>( 1 ,  2 ) X** ( 1 ,  2 ) </ul>
Cross With Power <ul>( 1 ,  2 ) X** ( 1 ,  2 ) 1 ,  1 ,  2 ,  4 </ul>
Metaops <ul>>> [ ] [ ] X Z S </ul>
Zip <ul>.zipwith() Z </ul>
Zip <ul>( 1 .. 10 ) Z < a .. j > < 1a 2b 3c 4d 5e 6f   ...> </ul>
Zip <ul>for   @a  Z  @b ->   $a ,  $b  { </ul>
Zip <ul>( 1 .. 4 ) Z+ ( 1 .. 4 ) </ul>
Zip <ul>( 1 .. 4 ) Z+ ( 1 .. 4 ) 2 ,  4 ,  6 ,  8 </ul>
Metaops <ul>>> [ ] [ ] X Z S </ul>
Sequence <ul>.sequence S </ul>
__END__ ?
=begin END
Danke
Upcoming SlideShare
Loading in …5
×

Perl 6 Datenstrukturen

427 views

Published on

Funktionsweisen der Perl 6 arrays and Hashes erklärt, mit Beispielen und einem lustigen Quiz

Published in: Technology, Economy & Finance
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
427
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • multiply a list
  • multiply a list
  • Perl 6 Datenstrukturen

    1. 1. Perl 6 Data Structures
    2. 2. Herbert Breunung
    3. 3. CPAN: lichtkind
    4. 4. Kephra 0.4.3.32
    5. 5. Kephra Logo
    6. 6. Als Hieroglyphe
    7. 7. Mansfelder Land
    8. 8. Mansfelder Land
    9. 9. Egypt aka Khem
    10. 10. Ein (K|C)amel
    11. 11. Noch ein Kamel?
    12. 12. Camelia
    13. 13. Camel ia
    14. 15. Schlaraffenland
    15. 16. Heiliger Gral
    16. 17. Schönheit Und Struktur
    17. 18. Datenstrukturen
    18. 20. @rrays Und %ashes
    19. 21. Auch $calare
    20. 22. Perl 5 <ul>@cities = ( 'roma' , 'milano' , 'torino' ); </ul>
    21. 23. Perl 5 & 6 <ul>@cities = ( 'roma' , 'milano' , 'torino' ); </ul>
    22. 24. Perl 5 <ul>@cities = qw( roma milano torino ); </ul>
    23. 25. Perl 6 <ul>@cities = qw( roma milano torino ); @cities = < roma milano torino >; </ul>
    24. 26. Mit Interpolation Wie “ “ <ul>@cities = qw( roma milano torino ); @cities = < roma milano torino >; @cities = << roma milano $city >>; </ul>
    25. 27. Perl 5 & 6 <ul>@cities = ( 'roma' , 'milano' , 'torino' ); </ul>
    26. 28. P5 & P6 <ul>@cities = ( 'roma' , 'milano' , 'torino' ); @cities = 'roma' , 'milano' , 'torino' ; </ul>
    27. 29. Klammern Gruppieren ! <ul>@cities = ( 'roma' , 'milano' , 'torino' ); @cities = 'roma' , 'milano' , 'torino' ; </ul>
    28. 30. Itemkontext <ul>$cities = ( 'roma' , 'milano' , 'torino' ); $cities = 'roma' , 'milano' , 'torino' ; </ul>
    29. 31. Itemkontext <ul># Parcel() $cities = ( 'roma' , 'milano' , 'torino' ); # Str() $cities = 'roma' , 'milano' , 'torino' ; </ul>
    30. 32. Was Ist Str ? <ul># Parcel() $cities = ( 'roma' , 'milano' , 'torino' ); # Str() - 'roma' ist ein String $cities = 'roma' , 'milano' , 'torino' ; </ul>
    31. 33. Nur Der Erste Wert <ul># Parcel() $cities = ( 'roma' , 'milano' , 'turino' ); # $a, $b, $c = 1, 2, 3; $cities = 'roma' , 'milano' , 'torino' ; </ul>
    32. 34. Was Ist Ein Parcel ? <ul># Parcel – Sequenz von Items $cities = ( 'roma' , 'milano' , 'torino' ); # Str() $cities = 'roma' , 'milano' , 'torino' ; </ul>
    33. 35. () Erinnert An Was? <ul># Parcel – wie in function(1,2,3); $cities = ( 'roma' , 'milano' , 'torino' ); # Str() $cities = 'roma' , 'milano' , 'torino' ; </ul>
    34. 36. Parcel <ul># hat pos. und benannte Args $cities = ( 'roma' , 'milano' , 'torino' ); # Str() $cities = 'roma' , 'milano' , 'torino' ; </ul>
    35. 37. Kontainertypen <ul># Array() $cities = [ 'roma' , 'milano' , 'torino' ]; # Parcel() $cities = ( 'roma' , 'milano' , 'torino' ); </ul>
    36. 38. Array() ne List() ne Parcel() <ul># List() $cities = @( 'roma' , 'milano' , 'torino' ); # Parcel() $cities = ( 'roma' , 'milano' , 'torino' ); </ul>
    37. 39. Nur Eine Liste <ul># List() $cities = list ( 'roma' , 'milano' , 'torino' ); # Parcel() $cities = ( 'roma' , 'milano' , 'torino' ); </ul>
    38. 40. Pos. Param. Als Liste <ul># List() $cities = list ( 'roma' , 'milano' , 'torino' ); # List() $cities = ||( 'roma' , 'milano' , 'torino' ); </ul>
    39. 41. Array Objekt <ul>$cities = [ 'roma' , 'milano' , 'torino' ]; @cities = 'roma' , 'milano' , 'torino' ; say $cities . WHAT # Array() say @cities . WHAT # Array() </ul>
    40. 42. Nummer An Elementen <ul>say length @cities ; # 3 say elems @cities ; # 3 # kein length </ul>
    41. 43. „ elems“ Ist Methode <ul>say length @cities ; # 3 say @cities . elems ; # 3 </ul>
    42. 44. An Jedem Arrayobjekt <ul>say scalar @$cities ; # 3 say $cities . elems ; # 3 </ul>
    43. 45. Inhalt Vom Skalar <ul>say “@$cities“ ; # roma ... say $cities ; # roma ... </ul>
    44. 46. Auch Im Skalarkontext <ul>say “@cities“ ; # roma ... say $( @cities ) ; # roma ... </ul>
    45. 47. Ich Meinte Itemkontext <ul>say “@cities“ ; # roma ... say item( @cities ) ; # roma ... </ul>
    46. 48. Numerischer Kontext <ul>say scalar @cities ; # 3 say + @cities ; # 3 </ul>
    47. 49. Numerischer Kontext <ul>say scalar @$cities ; # 3 say + $cities ; # 3 </ul>
    48. 50. Boolkontext <ul>say values @cities ; # romami... say ? @cities ; # Bool::True </ul>
    49. 51. Stringkontext <ul>say “@cities“ ; # roma milano say ~ @cities ; # roma milano ... </ul>
    50. 52. . Wurde ~ <ul>say “@cities“ ; # roma milano say “...“ ~ @cities ; # ...roma mila.. </ul>
    51. 53. Gehts Auch in P6 ? <ul>say “ @cities“ ; # roma milano torino say “@cities“ ; # roma milano torino? </ul>
    52. 54. Nicht Ganz <ul>say “@cities“ ; # roma milano ... say “@cities“ ; # @cities </ul>
    53. 55. Füge „[]“ An <ul>say “@cities“ ; # roma milano say “@cities[]“ ; # roma milano ... </ul>
    54. 56. Das War Kein Spezialfall <ul>say “@cities“ ; # roma milano say @cities [] ; # roma milano ... </ul>
    55. 57. Perl 5 & 6 <ul>say @cities ; # romamilanotorino say @cities ; # roma milano torino </ul>
    56. 58. Tiefer Als Listen
    57. 59. STD Perl 5 <ul>use Data::Dumper ; say Dumper ( @cities ); </ul>
    58. 60. $VAR1 = 2; $VAR2 = 3; $VAR3 = 4; $VAR4 = 5; $VAR5 = 6; $VAR6 = 7; $VAR7 = 7; $VAR8 = 2; $VAR9 = 5; $VAR10 = [ 'a', 'b', 'c' ]; [2, 3, 4, 5, 6, 7, 7, 2, 5, [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]] Data::Dumper Ausgabe
    59. 61. Er Hats Repariert <ul>use YAML ; # Data::Dumper sucks say Dump @cities ; </ul>
    60. 62. --- - 2 - 3 - 4 - 5 - 6 - 7 - 7 - 2 - 5 - - a - b - c [2, 3, 4, 5, 6, 7, 7, 2, 5, [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]] YAML Ausgabe
    61. 63. --- - 2 - 3 - 4 - 5 - 6 - 7 - 7 - 2 - 5 - - a - b - c [2, 3, 4, 5, 6, 7, 7, 2, 5, [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]] Er Kanns Kürzer
    62. 64. Perl 6 <ul>say @cities . perl ; </ul>
    63. 65. Mit eval Rückwandelbar <ul># in jeder Tiefe: say @cities . perl ; $ [&quot;roma&quot;, &quot;milano&quot;, &quot;torino&quot;] </ul>
    64. 66. Perl 5 <ul>say $cities [ 2 ]; # torino </ul>
    65. 67. Perl 6 <ul>say $cities [ 2 ]; # torino say @cities [ 2 ]; # torino </ul>
    66. 68. Array Als Item <ul>say $cities [ 2 ]; # in Perl 6 auch say @cities [ 2 ]; # torino </ul>
    67. 69. Der Selbe Kontainertyp <ul>$cities = [ 'roma' , 'milano' , 'torino' ]; say $cities [ 2 ]; # $cities.WHAT say @cities [ 2 ]; # @cities.WHAT </ul>
    68. 70. Arrayobjekt <ul>say $cities [ 2 ]; # Array() say @cities [ 2 ]; # Array() </ul>
    69. 71. Say Ist Eine Methode <ul>say $cities [ 2 ]; # torino @cities [ 2 ]. say ; # dito </ul>
    70. 72. [ ] Auch (Wie Jeder Op) <ul>say $cities .[ 2 ]; # 2 ist parameter @cities .[ 2 ]. say ; # dito </ul>
    71. 73. 2 ist Letzter Index <ul>say $cities [ 2 ]; # torino say @cities [ 2 ]; # dito </ul>
    72. 74. Perl 5 <ul>say $cities [ -1 ]; # torino say @cities [ 2 ]; # dito </ul>
    73. 75. Perl 6 <ul>say $cities [ -1 ]; # torino say @cities [* -1 ]; # dito </ul>
    74. 76. Whatever * <ul>say @cities [*- 1 ]; # torino </ul>
    75. 77. Whatever * <ul>say @cities [*- 1 ]; # torino # parameter „*-1“ ist eine closure </ul>
    76. 78. Whatever * <ul>say @cities [*- 1 ]; # torino # parameter „*-1“ ist eine closure # * ist parameter an diese closure </ul>
    77. 79. Whatever * <ul>say @cities [*- 1 ]; # turino # parameter „*-1“ ist eine closure # * ist parameter an diese closure # * enthält gesammten Array </ul>
    78. 80. Whatever * <ul>say @cities [*- 1 ]; # torino say @cities [* / 2 ]; # milano </ul>
    79. 81. Whatever * <ul>say “@cities“ ; # roma milano torino say @cities [*]; # roma milano torino </ul>
    80. 82. Whatever * <ul>say “@cities“ ; # roma milano torino say @cities []; # roma milano torino # default param ist * </ul>
    81. 83. LoL <ul>say @cities [ 1 ][ 1 ]; </ul>
    82. 84. List Of List <ul>@cities = [< roma .. >], [< berlin .. >]; say @cities [ 1 ][ 1 ]; say $cities [ 1 ; 1 ]; </ul>
    83. 85. Ein Spiel
    84. 86. Zähl die Schlümpfe
    85. 87. Zähle <ul>Wie viele Elemente hat diese Liste? </ul>
    86. 88. Count
    87. 89. Runde 1
    88. 90. Wie Viele Elemente ? <ul>my @number = 1 , 2 , 3 , 4 ; </ul>
    89. 91. Wie Viele Elemente ? <ul>my @number = 1 , 2 , 3 , 4 ; # 4 my @number = ( 1 , 2 , 3 , 4 ); </ul>
    90. 92. Wie Viele Elemente ? <ul>my @number = 1 , 2 , 3 , 4 ; # 4 my @number = ( 1 , 2 , 3 , 4 ); # 4 my @number = 1 , ( 2 , 3 ), 4 ; </ul>
    91. 93. Wie Viele Elemente ? <ul>my @number = 1 , 2 , 3 , 4 ; # 4 my @number = ( 1 , 2 , 3 , 4 ); # 4 my @number = 1 , ( 2 , 3 ), 4 ; # 4 my @number = 1 , [ 2 , 3 ], 4 ; </ul>
    92. 94. Wie Viele Elemente ? <ul>my @number = 1 , 2 , 3 , 4 ; # 4 my @number = ( 1 , 2 , 3 , 4 ); # 4 my @number = 1 , ( 2 , 3 ), 4 ; # 4 my @number = 1 , [ 2 , 3 ], 4 ; # 3 my @number = [ 1 , 2 , 3 , 4 ]; </ul>
    93. 95. Wie Viele Elemente ? <ul>my @number = 1 , 2 , 3 , 4 ; # 4 my @number = ( 1 , 2 , 3 , 4 ); # 4 my @number = 1 , ( 2 , 3 ), 4 ; # 4 my @number = 1 , [ 2 , 3 ], 4 ; # 3 my @number = [ 1 , 2 , 3 , 4 ]; # 1 mysub 1 ,( 2 ,[ 3 , 4 ]), 5 ; # in @_ </ul>
    94. 96. Wie Viele Elemente ? <ul>my @number = 1 , 2 , 3 , 4 ; # 4 my @number = ( 1 , 2 , 3 , 4 ); # 4 my @number = 1 , ( 2 , 3 ), 4 ; # 4 my @number = 1 , [ 2 , 3 ], 4 ; # 3 my @number = [ 1 , 2 , 3 , 4 ]; # 1 mysub 1 ,( 2 ,[ 3 , 4 ]), 5 ; # 4 # + Params. von außerhalb der ( ) </ul>
    95. 97. Runde 2
    96. 98. Wie Viele Elemente ? <ul>my $number = 1 , 2 , 3 , 4 ; </ul>
    97. 99. Wie Viele Elemente ? <ul>my $number = 1 , 2 , 3 , 4 ; # 1 my $number = ( 1 , 2 , 3 , 4 ); </ul>
    98. 100. Wie Viele Elemente ? <ul>my $number = 1 , 2 , 3 , 4 ; # 1 my $number = ( 1 , 2 , 3 , 4 ); # 4 my $number = 1 , ( 2 , 3 ), 4 ; </ul>
    99. 101. Wie Viele Elemente ? <ul>my $number = 1 , 2 , 3 , 4 ; # 1 my $number = ( 1 , 2 , 3 , 4 ); # 4 my $number = 1 , ( 2 , 3 ), 4 ; # 1 my $number = ( 1 , 2 ), 3 , 4 ; </ul>
    100. 102. Wie Viele Elemente ? <ul>my $number = 1 , 2 , 3 , 4 ; # 1 my $number = ( 1 , 2 , 3 , 4 ); # 4 my $number = 1 , ( 2 , 3 ), 4 ; # 1 my $number = ( 1 , 2 ), 3 , 4 ; # 2 my $number = ( 1 , [ 2 , 3 ], 4 ); </ul>
    101. 103. Wie Viele Elemente ? <ul>my $number = 1 , 2 , 3 , 4 ; # 1 my $number = ( 1 , 2 , 3 , 4 ); # 4 my $number = 1 , ( 2 , 3 ), 4 ; # 1 my $number = ( 1 , 2 ), 3 , 4 ; # 2 my $number = ( 1 , [ 2 , 3 ], 4 ); # 3 my $number = [ 1 , 2 , 3 , 4 ]; </ul>
    102. 104. Wie Viele Elemente ? <ul>my $number = 1 , 2 , 3 , 4 ; # 1 my $number = ( 1 , 2 , 3 , 4 ); # 4 my $number = 1 , ( 2 , 3 ), 4 ; # 1 my $number = ( 1 , 2 ), 3 , 4 ; # 2 my $number = ( 1 , [ 2 , 3 ], 4 ); # 3 my $number = [ 1 , 2 , 3 , 4 ]; # 4 </ul>
    103. 105. Runde 3
    104. 106. Wie Viele Elemente ? <ul>my $pd = my @pd = ( 3 , 1 , 4 , 1 ); </ul>
    105. 107. Wie Viele Elemente ? <ul>my $pd = my @pd = ( 3 , 1 , 4 , 1 ); @number = 1 , @pd , 4 ; </ul>
    106. 108. Wie Viele Elemente ? <ul>my $pd = my @pd = ( 3 , 1 , 4 , 1 ); @number = 1 , @pd , 4 ; # 6 @number = 1 , $pd , 4 ; </ul>
    107. 109. Wie Viele Elemente ? <ul>my $pd = my @pd = ( 3 , 1 , 4 , 1 ); @number = 1 , @pd , 4 ; # 6 @number = 1 , $pd , 4 ; # 3 @number = 1 , @pd . item , 4 ; </ul>
    108. 110. item & list == Konextops <ul>my $pd = my @pd = ( 3 , 1 , 4 , 1 ); @number = 1 , @pd , 4 ; # 6 @number = 1 , $pd , 4 ; # 3 @number = 1 , @pd . item , 4 ; # 3 @number = 1 , $pd . list , 4 ; </ul>
    109. 111. Wie Viele Elemente ? <ul>my $pd = my @pd = ( 3 , 1 , 4 , 1 ); @number = 1 , @pd , 4 ; # 6 @number = 1 , $pd , 4 ; # 3 @number = 1 , @pd . item , 4 ; # 3 @number = 1 , $pd . list , 4 ; # 6 @number = Nil , Nil , Nil ; </ul>
    110. 112. Nil != undef <ul>my $pd = my @pd = ( 3 , 1 , 4 , 1 ); @number = 1 , @pd , 4 ; # 6 @number = 1 , $pd , 4 ; # 3 @number = 1 , @pd . item , 4 ; # 3 @number = 1 , $pd . list , 4 ; # 6 @number = Nil , Nil , Nil ; # 0 </ul>
    111. 113. And The Winner Is ...
    112. 114. Perl 5 <ul>@digits = ( 4 ) x 5 ; # (4,4,4,4,4) </ul>
    113. 115. Perl 6 <ul>@digits = ( 4 ) x 5 ; # (4,4,4,4,4) @digits = ( 4 ) xx 5 ; # 4,4,4,4,4 </ul>
    114. 116. Verfielfacht Listen <ul>@digits = ( 4 ) x 5 ; # (4,4,4,4,4) @digits = 4 xx 5 ; # 4,4,4,4,4 </ul>
    115. 117. Verfielfacht Strings <ul>@digits = 4 x 5 ; # '44444' @digits = 4 x 5 ; # '44444' </ul>
    116. 118. Verfielfacht Strings <ul>@digits = 4 x 5 ; # '44444' @digits = ( 4 ) x 5 ; # '44444' </ul>
    117. 119. Verfielfacht Strings <ul>@digits = '1 2' x 3 ; # '1 21 21 2' @digits = ( 1 , 2 ) x 3 ; # '1 21 21 2' </ul>
    118. 120. Verfielfacht Listen <ul>@digits = ( 1 , 2 ) x 3 ; # 1,2,1,2,1,2 @digits = ( 1 , 2 ) xx 3 ; # 1,2,1,2,1,2 </ul>
    119. 121. Perl 5 <ul>@digits = ( 0 .. 9 ); # Bereichsop </ul>
    120. 122. Perl 5 & 6 <ul>@digits = ( 0 .. 9 ); </ul>
    121. 123. Perl 6 <ul>@digits = 0 .. 9 ; </ul>
    122. 124. Perl 6 <ul>@digits = ^ 10 ; # 0 .. 9 </ul>
    123. 125. 0 Ist Gegeben <ul>@digits = 0 ..^ 10 ; # 0 .. 9 (@) </ul>
    124. 126. ^ Schließt Schranke Aus <ul>@digits = -1 ^..^ 10 ; # 0 .. 9 </ul>
    125. 127. Sequence - Operator <ul>@digits = 0 ... 9 ; </ul>
    126. 128. Linear <ul>@digits = 0 ... 9 ; # 0 .. 9 </ul>
    127. 129. Arithmetisch <ul>@digits = 0 ... 9 ; # 0 .. 9 @odd = 1 , 3 … 9 ; # 1,3,5,7,9 </ul>
    128. 130. Geometrisch <ul>@digits = 0 ... 9 ; # 0 .. 9 @odd = 1 , 3 … 9 ; # 1,3,5,7,9 @bin = 1 , 2 , 4 … 1024 ; #..,8,16,32,. </ul>
    129. 131. Fibonacci <ul>@digits = 0 ... 9 ; # 0 .. 9 @odd = 1 , 3 … 9 ; # 1,3,5,7,9 @bin = 1 , 2 , 4 … 1024 ; #..,8,16,32,. @fib = 0 , 1 ,*+* … 144 ; #..,1,2,3,.. </ul>
    130. 132. Prüf Das Limit <ul>@odd = 1 , 3 … 10 ; # 1,3,.. * </ul>
    131. 133. Unendliche Liste <ul>@odd = 1 , 3 … 10 ; # 1,3,.. * @number = 0 .. *; # 0 .. Inf </ul>
    132. 134. Bestimmte Elemente <ul>@odd = 1 , 3 … 10 ; # 1,3,.. * @number = 0 .. *; # 0 .. Inf say @odd [ 1 ]; # 3 say @number [ 5 ]; # 4 </ul>
    133. 135. Alle Elemente <ul>@odd = 1 , 3 … 10 ; # 1,3,.. * @number = 0 .. *; # 0 .. Inf say @odd [*]; # warten ... say @number ; # viele Ziffern </ul>
    134. 136. Anzahl Der Elemente <ul>@odd = 1 , 3 … 10 ; # 1,3,.. * @number = 0 .. *; # 0 .. Inf say + @odd ; # warten ... say @number ; # viele Ziffern </ul>
    135. 137. Was ist geschehen? <ul>$number = 0 .. *; # 0 .. Inf say $number . WHAT ; # Range() </ul>
    136. 138. Ausgabe ? <ul>$number = 0 .. *; # 0 .. Inf say $number ; # ? </ul>
    137. 139. Erstes Element <ul>$number = 0 .. *; # 0 .. Inf say $number ; # 0 </ul>
    138. 140. Unendliche Liste <ul>$number = 0 .. *; # 0 .. Inf say @( $number ); # digits ... </ul>
    139. 141. Array <ul>@number = 0 .. *; # 0 .. Inf say @number [ 5 ]; </ul>
    140. 142. Bei Bedarf Erzeugt <ul>@number = 0 .. *; # 0 .. Inf say @number [ 5 ]; # @number.reify(5) </ul>
    141. 143. Interne Repräsentation <ul>@number = 0 .. *; # 0 .. Inf say @number . reify ( 5 ). perl ; # (0, 1, 2, 3, 4, 5, 6..*) </ul>
    142. 144. Ihr Kennt Diese <ul>shift unshift push pop splice reverse map grep </ul>
    143. 145. Perl 5 <ul>%opera = ( 'verdi' => 'Aida' , 'puccini' => 'Turandot' , 'rossini' => 'Il barbiere' , ); </ul>
    144. 146. Perl 6 <ul>%opera = ( 'verdi' => 'Aida' , 'puccini' => 'Turandot' , 'rossini' => 'Il barbiere' , ); </ul>
    145. 147. Kein Gruppieren Nötig <ul>%opera = 'verdi' => 'Aida' , 'puccini' => 'Turandot' , 'rossini' => 'Il barbiere' , ; </ul>
    146. 148. Immer Noch Ein Hash <ul>%opera = 'verdi' => 'Aida' , 'puccini' => 'Turandot' , 'rossini' => 'Il barbiere' , ; %opera . WHAT eq 'Hash()' </ul>
    147. 149. Neuer Paar-Syntax <ul>%opera = : verdi ( 'Aida' ), : puccini ( 'Turandot' ), : rossini ( 'Il barbiere' ), ; %opera . WHAT eq 'Hash()' </ul>
    148. 150. Mit Autoquoting <ul>%opera = : verdi < Aida >, : puccini < Turandot >, : rossini < Il barbiere >, ; %opera . WHAT eq 'Hash()' </ul>
    149. 151. Item - Kontext <ul>$opera = : verdi < Aida >, : puccini < Turandot >, : rossini < Il barbiere >, ; $opera . WHAT eq 'Pair()' </ul>
    150. 152. Gruppiert <ul>$opera = ( : verdi < Aida >, : puccini < Turandot >, : rossini < Il barbiere >, ); %opera . WHAT eq 'Parcel()' </ul>
    151. 153. Packet Kennt Pos. <ul>$opera = ( : verdi < Aida >, : puccini < Turandot >, : rossini < Il barbiere >, ); 0 verdi Aida 1 puccini Turandot 2 rossini Il barbiere </ul>
    152. 154. Hashkontext - Op <ul>$opera = %( : verdi < Aida >, : puccini < Turandot >, : rossini < Il barbiere >, ); %opera . WHAT eq 'Hash()' </ul>
    153. 155. Hashkontext - Op <ul>$opera = hash( : verdi < Aida >, : puccini < Turandot >, : rossini < Il barbiere >, ); %opera . WHAT eq 'Hash()' </ul>
    154. 156. Hash-Generator-Op <ul>$opera = { : verdi < Aida >, : puccini < Turandot >, : rossini < Il barbiere >, }; %opera . WHAT eq 'Hash()' </ul>
    155. 157. Hash - Generator - Op <ul>%opera = { : verdi < Aida >, : puccini < Turandot >, : rossini < Il barbiere >, }; %opera . WHAT eq 'Hash()' </ul>
    156. 158. Invariante Sigils <ul>%opera { 'rossini' }; # Il barbiere </ul>
    157. 159. Invariante Sigils <ul>%opera .{ 'rossini' }; # alias .at_key() </ul>
    158. 160. Erinnern An qw() ? <ul>%opera { 'rossini' }; # Il barbiere %opera < rossini >; </ul>
    159. 161. Mit Interpolation <ul>%opera { 'rossini' }; # Il barbiere %opera < rossini >; %opera << $autore >>; </ul>
    160. 162. 2 Opern Auf Einmal <ul>%opera { 'rossini' , 'puccini' }; %opera < rossini puccini >; %opera << @autore >>; </ul>
    161. 163. Sind Auch Hashes <ul>$opera { 'rossini' , 'puccini' }; $opera < rossini puccini >; $opera << @autore >>; </ul>
    162. 164. Auch Mit Parcel() <ul># oder Capture() $opera { 'rossini' , 'puccini' }; $opera < rossini puccini >; $opera << @autore >>; </ul>
    163. 165. Hash Methoden <ul>%opera . keys ; # verdi puccini ro... %opera . values ; # aida turandot ... %opera . kv ; # verdi aida puccini ... </ul>
    164. 166. Haben Arrays Auch <ul>@cities . keys ; # 0 1 2 @cities . values ; # roma milano ... @cities . kv ; # 0 roma 1 milano 2 ... </ul>
    165. 167. Auch Paare <ul>$opera . key ; # rossini $opera . value ; # Il barbiere $opera ; # </ul>
    166. 168. Mehr Hash Methoden <ul>%opera . pairs ; # list of pair obj. %opera . exists ; # Bool %opera . delete ; # 1 | 0 </ul>
    167. 169. Mehr Hash Methoden <ul>%opera . pairs ; # list of pair obj. %opera . exists ; # one at a time %opera . delete ; # one at a time </ul>
    168. 170. Hash Im Kontext <ul>? %opera ; # bool Kontext + %opera ; # num Kontext ~ %opera ; # string Kontext </ul>
    169. 171. Hash Im Kontext <ul>? %opera ; # Bool::True + %opera ; # 3 ~ %opera ; # rossini Il barbiere </ul>
    170. 172. Value Im Kontext <ul>? %opera ; # Bool::True + %opera ; # 3 ~ %opera ; # rossini Il barbiere </ul>
    171. 173. Neue Hashmethoden <ul>say %opera . invert ; Aida verdi Turandot puccini Il barbiere rossini </ul>
    172. 174. Hash Erzeuger <ul>my %h = @cities . classify ( { uc substr ( $_ , 0 , 1 ) } ); say %h ; $ R roma M milano T torino </ul>
    173. 175. Hash Erzeuger <ul>@cities . categorize ({ catsub ( $_ ) }); say %h . perl ; </ul>
    174. 176. Hash Erzeuger <ul>@cities . categorize ({ water ( $_ ) }); say %h . perl ; {&quot;mare&quot; => [&quot;roma&quot;], &quot;fiume&quot; => [&quot;roma&quot;, &quot;milano&quot;, &quot;torino&quot;], &quot;lago&quot; => Nil} </ul>
    175. 177. ==> <ul>Pipes </ul>
    176. 178. Schwartz. Transform <ul>@results = map {…}, sort {…}, map {...}, @input ; </ul>
    177. 179. Schwartz. Transform <ul>@results = map {…}, sort {…}, map {...}, @input ; @results = map {…} <== sort {…} <== map {…} <== @input ; </ul>
    178. 180. Schwartz. Transform <ul>@results = map {…}, sort {…}, map {...}, @input ; @results <== map {…} <== sort {…} <== map {…} <== @input ; </ul>
    179. 181. Schwartz. Transform <ul>@results = map {…}, sort {…}, map {...}, @input ; @input ==> map {…} ==> sort {…} ==> map {…} ==> @results ; </ul>
    180. 182. Metaops
    181. 183. Metaops <ul>= ! R </ul>
    182. 184. Metaops <ul>>> [ ] [ ] X Z S </ul>
    183. 185. Metaops <ul>>> [ ] [ ] X Z S </ul>
    184. 186. Hyperoperator <ul>>> </ul>
    185. 187. Hyperoperator <ul>>> .hyper() </ul>
    186. 188. Simple Example <ul>( 1 .. 5 ) >>++ </ul>
    187. 189. That Works <ul>@number >>++ </ul>
    188. 190. Result <ul>@number >>++ 2 , 3 , 4 , 5 , 6 </ul>
    189. 191. More Complicated <ul>( 1 .. 5 ) >>+>> 1 </ul>
    190. 192. Check Your Spaces <ul>(1..5) _ >>+>> _ 1 </ul>
    191. 193. Same Result <ul>( 1 .. 5 ) >>+>> 1 2 , 3 , 4 , 5 , 6 </ul>
    192. 194. Reverse Hyper <ul>( 1 .. 5 ) <<+<< 1 </ul>
    193. 195. Right Side Rules <ul>( 1 .. 5 ) <<+<< 1 2 </ul>
    194. 196. Both Rule ? <ul>( 1 .. 5 ) >>+<< 1 </ul>
    195. 197. Yes Both! <ul>( 1 .. 5 ) >>+<< 1 Runtime Error !!! </ul>
    196. 198. Preserves LoL ? <ul>( 1 .. 5 , [ 6 .. 9 ]) >>+>> 1 </ul>
    197. 199. Preserves LoL ! <ul>( 1 .. 5 , [ 6 .. 9 ]) >>+>> 1 2 , 3 , 4 , 5 , 6 , [ 7 , 8 , 9 , 10 ] </ul>
    198. 200. On 2 Sides ? <ul>( 1 .. 5 , [ 6 .. 9 ]) >>+<< ( 0 .. 4 , [ 1 .. 4 ]) </ul>
    199. 201. On 2 Sides ! <ul>( 1 .. 5 , [ 6 .. 9 ]) >>+<< ( 0 .. 4 , [ 1 .. 4 ]) ( 1 , 3 , 5 , 7 , 9 , [ 7 , 9 , 11 , 13 ]) </ul>
    200. 202. How About This? <ul>( 1 .. 5 , [ 6 .. 9 ]) >>+<< ( 0 .. 4 , [ 1 .. 5 ]) </ul>
    201. 203. Checks Lengths <ul>( 1 .. 5 , [ 6 .. 9 ]) >>+<< ( 0 .. 4 , [ 1 .. 5 ]) Runtime Error </ul>
    202. 204. Reduce <ul>[ ] .reduce </ul>
    203. 205. Do The Gauss <ul>[+] ( 1 .. 100 ) </ul>
    204. 206. Do The Gauss <ul>[+] ( 1 .. 100 ) 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + ... </ul>
    205. 207. 100+1 * 50 <ul>[+] ( 1 .. 100 ) 5050 </ul>
    206. 208. Chained Comparsion <ul>[<] ( 1 .. 100 ) </ul>
    207. 209. Chained Comparsion <ul>[<] ( 1 .. 100 ) 1 < 2 < 3 < 4 < 5 < 6 < 7 < 8 < ... </ul>
    208. 210. Chained Comparsion <ul>[<] ( 1 .. 100 ) Bool::True </ul>
    209. 211. Junction <ul>all ( 1 .. 100 ) > 0 </ul>
    210. 212. Junction <ul>all ( 1 .. 100 ) 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ... </ul>
    211. 213. Junction <ul>all ( 1 .. 100 ) > 0 ( True , True , True , True , ... </ul>
    212. 214. Bool Context <ul>? all ( 1 .. 100 ) > 0 True </ul>
    213. 215. Bool Context <ul>? all ( 1 .. 100 ) > 1 False </ul>
    214. 216. Metaops <ul>>> [ ] [ ] X Z S </ul>
    215. 217. Triangle <ul>[ ] triangle() </ul>
    216. 218. Back To Gauss <ul>[+] ( 1 .. 100 ) </ul>
    217. 219. Returns A List <ul>[+] ( 1 .. 100 ) ((((( 1 ) + 2 ) + 3 ) + 4 ) + 5 ) + 6 ) + ... </ul>
    218. 220. Returns A List <ul>[+] ( 1 .. 100 ) ( 1 , 3 , 6 , 10 , 15 , 21 , 28 , ... </ul>
    219. 221. Metaops <ul>>> [ ] [ ] X Z S </ul>
    220. 222. Cross <ul>.crosswith X </ul>
    221. 223. Cross <ul>( 1 , 2 ) X ( 1 , 2 ) 11 , 12 , 21 , 22 </ul>
    222. 224. Cross With Power <ul>( 1 , 2 ) X** ( 1 , 2 ) </ul>
    223. 225. Cross With Power <ul>( 1 , 2 ) X** ( 1 , 2 ) 1 , 1 , 2 , 4 </ul>
    224. 226. Metaops <ul>>> [ ] [ ] X Z S </ul>
    225. 227. Zip <ul>.zipwith() Z </ul>
    226. 228. Zip <ul>( 1 .. 10 ) Z < a .. j > < 1a 2b 3c 4d 5e 6f ...> </ul>
    227. 229. Zip <ul>for @a Z @b -> $a , $b { </ul>
    228. 230. Zip <ul>( 1 .. 4 ) Z+ ( 1 .. 4 ) </ul>
    229. 231. Zip <ul>( 1 .. 4 ) Z+ ( 1 .. 4 ) 2 , 4 , 6 , 8 </ul>
    230. 232. Metaops <ul>>> [ ] [ ] X Z S </ul>
    231. 233. Sequence <ul>.sequence S </ul>
    232. 234. __END__ ?
    233. 235. =begin END
    234. 236. Danke

    ×