in reply to Re: Applying an array to a function
in thread Applying an array to a function

Since you were trying to simplify the code, it should be noted that
my $array = []; @{$array} = ($x) x $n; return $array;
is a complicated way of writing
my @array = ($x) x $n; return \@array;
or
my $array = [ ($x) x $n ]; return $array;
or
return [ ($x) x $n ];

Replies are listed 'Best First'.
Re^3: Applying an array to a function
by eklerks (Novice) on Jun 02, 2010 at 14:10 UTC
    I use haskell a lot lately and it is nice to see that your last version is very close to how you can implement repeat into haskell:
    repeat a = [a,a..]
    Perl can be a really concise language. It astonish me time after time. I am really looking forward to perl6. (In haskell it is an infinite list, how is this in perl6?)
    I got the answer already. Perl6 is also lazy evaluated, so infinite lists are supported.