<code>
#include <stdio.h>
void print(int y[])
{
int ii;
for (ii = 0; 9 > ii; ++ii)
{
printf("%d ", y[ii]);
}
printf("\n");
}
int main()
{
int x = 0; int y[] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; y[x++]++; /* line
that matters */
printf("%d\n", x);
print(y);
return 0;
}
</code>
in perl5, i would've written something like:
<code>
my $x = 0; my @y = 1..9; @y[$x++]++; print "$x\n"; print "@y\n"
</code>
but in perl6, the '@' sigil always means list context, so should i
write the following?
<code>
my $x = 0; my @y = 1..9; ${@y[${$x++}]}++; print "$x\n"; print "@y\n"
</code>
-xgl
Um ... do you mean s/perl6/perl5/ above? In perl6 the @ sigil does
not always mean list context; it just means that you're dealing with
an array somehow.
Your code above is practically perl6 already. The only problem with
it that I see is that you need to use @y[] to interpolate an array
into a string:
my $x = 0; my @y = 1..9; @y[$x++]++; print "$x\n"; print "@y[]\n"
-Scott
--
Jonathan Scott Duff
du...@pobox.com