topaz has asked for the wisdom of the Perl Monks concerning the following question:
For example: 100 2 -2 44 150 9 26 -4 150 9 0 -1
I want to create a 2 dimensional array 361x361 and set it to zero then start recording the count of combination $a $b the combination of 150 and 9 appeared twice on the list so the count will be 2 can I do something like this ?
my @a = ((0) x 361); my @b = ((0) x 361); my @matrix = (@a,@b) while ($line = <IN>) { @record = split(/\s+/, $line); $a = $record[0]; $b = $record[1]; @matrix [$a+180][$b+180] ++; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: 2 D array
by ikegami (Patriarch) on Jul 28, 2011 at 22:05 UTC | |
by topaz (Initiate) on Jul 28, 2011 at 23:53 UTC | |
by ikegami (Patriarch) on Jul 29, 2011 at 01:01 UTC | |
by ff (Hermit) on Jul 29, 2011 at 01:46 UTC | |
by ikegami (Patriarch) on Jul 29, 2011 at 04:28 UTC | |
by ff (Hermit) on Jul 29, 2011 at 17:41 UTC | |
|
Re: 2 D array
by BrowserUk (Patriarch) on Jul 29, 2011 at 04:36 UTC |