Functional List Processing
List Slices
Select a small window from a list.
list-slices
A slice selects particular positions from a list. Slices are useful when a program needs a short window of values.
List Slices
list_slices.pl
Replay: real traced execution (multi-file project)
use strict;
use warnings;
my $start = 1;
my @letters = ("a", "b", "c", "d");
my @window = @letters[$start, $start + 1];
my $joined = join("", @window);
print "start=$start\n";
print "window=$joined\n";
use strict;
use warnings;
my $start = 0;
my @letters = ("a", "b", "c", "d");
my @window = @letters[$start, $start + 1];
my $joined = join("", @window);
print "start=$start\n";
print "window=$joined\n";
$start ← 1, @letters ← 4, @window ← 2, $joined ← bc
4my $start→ 1 = 1; #@start=05my @letters→ 4 = ("a", "b", "c", "d");6my @window→ 2 = @letters[$start, $start + 1];7my $joined→ bc = join("", @window2);89print "start=$start1\n";10print "window=$joinedbc\n";outputstart=1 window=bc
$start ← 0, @letters ← 4, @window ← 2, $joined ← ab
4my $start→ 0 = 0;5my @letters→ 4 = ("a", "b", "c", "d");6my @window→ 2 = @letters[$start, $start + 1];7my $joined→ ab = join("", @window2);89print "start=$start0\n";10print "window=$joinedab\n";outputstart=0 window=ab