in reply to Re^2: enumerating values for slopes
in thread enumerating values for slopes
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: enumerating values for slopes
by Aldebaran (Curate) on Sep 23, 2014 at 05:04 UTC | |
Thought I would be comparing hypotenuses to heights but can't see why perl doesn't this is ok. | [reply] [d/l] |
by Laurent_R (Canon) on Sep 23, 2014 at 17:36 UTC | |
you are not creating an array of arrays (AoA), but a simple array whose 4 elements are: You need to push or build I guess this should solve your issue. 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. | [reply] [d/l] [select] |
by farang (Chaplain) on Sep 24, 2014 at 02:07 UTC | |
You need to push on @AoA a reference to @vector:That way is buggy, though, as the redefinition of @vector will clobber the first pushed array element. This is explained under COMMON MISTAKES in perldsc, "taking a reference to the same memory location repeatedly". So both lines above should instead use a square bracket reference.
| [reply] [d/l] [select] |
by Laurent_R (Canon) on Sep 24, 2014 at 06:59 UTC | |
by Aldebaran (Curate) on Sep 24, 2014 at 06:30 UTC | |
This might be the most robust version of this material. | [reply] [d/l] |
by Laurent_R (Canon) on Sep 23, 2014 at 06:11 UTC | |
| [reply] [d/l] |
by Aldebaran (Curate) on Sep 23, 2014 at 07:10 UTC | |
| [reply] [d/l] |
by Aldebaran (Curate) on Sep 23, 2014 at 06:40 UTC | |
What I found when field measuring was that it was much more attainable to get hypotenuses and heights, so that left me looking for arcsin. I had hoped to get this processed as an AoA, but I'm not quite there yet....
| [reply] [d/l] |