in reply to Re^4: enumerating values for slopes
in thread enumerating values for slopes
you are not creating an array of arrays (AoA), but a simple array whose 4 elements are:my @vector = (4.3125, 0.4375); push @AoA, @vector; @vector = (4.375, 0.375); push @AoA, @vector;
You need to push(4.3125, 0.4375, 4.375, 0.375)
or buildmy @vector = (4.3125, 0.4375); push @AoA, \@vector; @vector = (4.375, 0.375); push @AoA, \@vector;
I guess this should solve your issue.push @AoA, [4.3125, 0.4375]; push @AoA, [4.375, 0.375];
As I said earlier, you should avoid using the $a and $b variables, they are special variables used among other things for sorting, they behave differently from other variables, and using as you do them might lead to difficult-to-track bugs. You may use $c or $d, if you like, this will not be a problem, but I would personally put a more meaningful name helping comprehension of what they represent.
Update: As pointed below by farang the first method above for building an AoA is actually buggy. Use the second one. Thanks to farang for picking that.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: enumerating values for slopes
by farang (Chaplain) on Sep 24, 2014 at 02:07 UTC | |
by Laurent_R (Canon) on Sep 24, 2014 at 06:59 UTC | |
|
Re^6: enumerating values for slopes
by Aldebaran (Curate) on Sep 24, 2014 at 06:30 UTC |