aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Ferrari <fluca1978@gmail.com>2020-07-27 12:06:19 +0200
committerLuca Ferrari <fluca1978@gmail.com>2020-07-27 12:06:19 +0200
commit10f59d76ab8043d29c5d43c2918f386cafb8bb99 (patch)
tree381ed780b3fcb962cf9592846669acf3b46f35b3
parent3b70cc0bc2867dbfe9e2d7606f81794ee7e6e57c (diff)
downloadperlweeklychallenge-club-10f59d76ab8043d29c5d43c2918f386cafb8bb99.tar.gz
perlweeklychallenge-club-10f59d76ab8043d29c5d43c2918f386cafb8bb99.tar.bz2
perlweeklychallenge-club-10f59d76ab8043d29c5d43c2918f386cafb8bb99.zip
Rename root to head, since it is a list.
-rw-r--r--challenge-071/luca-ferrari/raku/ch-2.p618
1 files changed, 9 insertions, 9 deletions
diff --git a/challenge-071/luca-ferrari/raku/ch-2.p6 b/challenge-071/luca-ferrari/raku/ch-2.p6
index 43e64e31ed..947f83a1ca 100644
--- a/challenge-071/luca-ferrari/raku/ch-2.p6
+++ b/challenge-071/luca-ferrari/raku/ch-2.p6
@@ -36,17 +36,17 @@ sub MAIN( Int $N where { $N > 0 }, *@list ) {
# build the list backward and keep the root
# at the list
- my $root = Nil;
+ my $head = Nil;
my $current = Nil;
loop ( my $i = @list.elems - 1; $i >= 0; $i-- ) {
- $root = Node.new( value => @list[ $i ],
- next => $root );
+ $head = Node.new( value => @list[ $i ],
+ next => $head );
}
# compute the size of the list
- my $size-of-the-list = $root.size;
+ my $size-of-the-list = $head.size;
"Size of the list is $size-of-the-list".say;
- $root.put;
+ $head.put;
@@ -57,12 +57,12 @@ sub MAIN( Int $N where { $N > 0 }, *@list ) {
# particular case: remove the root
- $root = $root.next if ( $index == $index-to-remove || $N > $size-of-the-list );
+ $head = $head.next if ( $index == $index-to-remove || $N > $size-of-the-list );
# remove a specific element, but only if this has not been already done
# by removing the root element and thus changing the size of the list
- if ( $root.size == $size-of-the-list ) {
- $current = $root;
+ if ( $head.size == $size-of-the-list ) {
+ $current = $head;
while ( $current ) {
if ( ( $index + 1 ) == ( $size-of-the-list - $N + 1 ) ) {
$current.next = $current.next.next;
@@ -76,6 +76,6 @@ sub MAIN( Int $N where { $N > 0 }, *@list ) {
# print the modified list
- $root.put;
+ $head.put;
}