Mine
public text v1 · immutablemy $foo = [ 'a', ['b', 'c', [ 'd' ]] ];
print counter($foo);
sub counter {
my $foo = shift;
my $count = 0;
foreach (@$foo) { $count += ref($_) eq 'ARRAY'? counter($_) : 1; }
$count;
}
my $foo = [ 'a', ['b', 'c', [ 'd' ]] ];
print counter($foo);
sub counter {
my $foo = shift;
my $count = 0;
foreach (@$foo) { $count += ref($_) eq 'ARRAY'? counter($_) : 1; }
$count;
}