- or download this
sub up
{
...
($row * $col > 0 && up( ~-$row . '-' . ~-$col, @_ ) ) .
($row > $col && up( ~-$row . '-' . $col, @_ ) );
}
- or download this
sub up{
# indent to evidentiate the recursive function level
...
($row > $col && up( ~-$row . '-' . $col, @_ ) );
}
}
- or download this
@_ = [3-1]
3 * 1 > 0 && up(2-0, 3-1) # decremented both row and column are passed
+ plus original @_
...
RETURNING: @_ is a valid path [0-0 1-1 2-1 3-1]
1 > 1 is FALSE...
"0-0 1-0 2-0 3-1\n0-0 1-0 2-1 3-1\n0-0 1-1 2-1 3-1\n"
- or download this
# receives and returns aoa
sub up_modified{
...
);
}
}
- or download this
@_ is [[3, 1]]
receiving row 3 col 1
...
@_ is [[0, 0], [1, 1], [2, 1], [3, 1]]
receiving row 0 col 0
RETURNING: [[0, 0], [1, 1], [2, 1], [3, 1]]
- or download this
sub up_modified_bis{
my $ind = ' ' x $#_ x 4;
...
@_ is ([0, 0], [1, 1], [2, 1], [3, 1])
receiving row 0 col 0
RETURNING: ([0, 0], [1, 1], [2, 1], [3, 1])