home | blog

Perl 6 screencast - part 3 - arrays and ranges

Published on 2010.07.22 at 11:38:18 Bookmark and Share

Tags: Perl 6, Perl, screencast, arrays, ranges


Direct link to the Perl 6 arrays and ranges screencast

See more Perl 6 entries.

Perl 6 Code examples

  use v6;
  my @people = ;
  for @people -> $n {
    say $n;
  }


  use v6;
  my @people = ;
  for 0 .. @people.elems/2 -> $i {
    say "@people[$i*2] -  @people[$i*2+1]";
  }


  use v6;
  my @people = ;
  for @people -> $name, $phone {
    say "$name - $phone";
  }


  use v6;
  my @names = ;
  my @phones = <123 456 789 512>;
  for @names Z @phones -> $name, $phone {
    say "$name - $phone";
  }


  use v6;
  for 1 .. 10 -> $n {
    say $n;
  }


  use v6;
  for 1,3 ... Inf -> $n {
    say $n;
    last if $n > 10;
  }


blog comments powered by Disqus
Follow szabgab on Twitter
Tags
Perl (270)
Perl 5 (94)
Padre (79)
Perl 6 (42)
IDE (41)
testing (38)
CPAN (28)
business (27)
newsletter (24)
marketing (23)
training (20)
TPF (17)
open source (17)
Windows (17)
promotion (17)
Parrot (16)
YAPC (16)
Israel (15)
grants (15)
Python (14)