in reply to Re: enumerating values for slopes
in thread enumerating values for slopes
$ perl slope3.pl Prototype mismatch: sub math1::pi () vs none at ../math1.pm line 13. Constant subroutine pi redefined at ../math1.pm line 7. Subroutine main::pi redefined at /usr/share/perl/5.18/Exporter.pm line + 66. at slope3.pl line 6. Prototype mismatch: sub main::pi: none vs () at /usr/share/perl/5.18/E +xporter.pm line 66. at slope3.pl line 6. slopes are 0 5 8 11 14 30 90 runs are 2.25 3.25 4 5 An angle of 0 degrees, or 0 radians, and run of 2.25 has a rise of 0 An angle of 0 degrees, or 0 radians, and run of 3.25 has a rise of 0 An angle of 0 degrees, or 0 radians, and run of 4 has a rise of 0 An angle of 0 degrees, or 0 radians, and run of 5 has a rise of 0 An angle of 5 degrees, or 0.0872664625997165 radians, and run of 2.25 +has a rise of 0.196849492933329 An angle of 5 degrees, or 0.0872664625997165 radians, and run of 3.25 +has a rise of 0.284338156459253 An angle of 5 degrees, or 0.0872664625997165 radians, and run of 4 has + a rise of 0.349954654103696 An angle of 5 degrees, or 0.0872664625997165 radians, and run of 5 has + a rise of 0.43744331762962 An angle of 8 degrees, or 0.139626340159546 radians, and run of 2.25 h +as a rise of 0.316216878080381 An angle of 8 degrees, or 0.139626340159546 radians, and run of 3.25 h +as a rise of 0.456757712782772 An angle of 8 degrees, or 0.139626340159546 radians, and run of 4 has +a rise of 0.562163338809566 An angle of 8 degrees, or 0.139626340159546 radians, and run of 5 has +a rise of 0.702704173511957 An angle of 11 degrees, or 0.191986217719376 radians, and run of 2.25 +has a rise of 0.437355695559867 An angle of 11 degrees, or 0.191986217719376 radians, and run of 3.25 +has a rise of 0.631736004697585 An angle of 11 degrees, or 0.191986217719376 radians, and run of 4 has + a rise of 0.777521236550874 An angle of 11 degrees, or 0.191986217719376 radians, and run of 5 has + a rise of 0.971901545688592 An angle of 14 degrees, or 0.244346095279206 radians, and run of 2.25 +has a rise of 0.560988006397157 An angle of 14 degrees, or 0.244346095279206 radians, and run of 3.25 +has a rise of 0.810316009240337 An angle of 14 degrees, or 0.244346095279206 radians, and run of 4 has + a rise of 0.997312011372723 An angle of 14 degrees, or 0.244346095279206 radians, and run of 5 has + a rise of 1.2466400142159 An angle of 30 degrees, or 0.523598775598299 radians, and run of 2.25 +has a rise of 1.29903810567666 An angle of 30 degrees, or 0.523598775598299 radians, and run of 3.25 +has a rise of 1.87638837486628 An angle of 30 degrees, or 0.523598775598299 radians, and run of 4 has + a rise of 2.3094010767585 An angle of 30 degrees, or 0.523598775598299 radians, and run of 5 has + a rise of 2.88675134594813 An angle of 90 degrees, or 1.5707963267949 radians, and run of 2.25 ha +s a rise of 3.67452885446896e+16 An angle of 90 degrees, or 1.5707963267949 radians, and run of 3.25 ha +s a rise of 5.3076527897885e+16 An angle of 90 degrees, or 1.5707963267949 radians, and run of 4 has a + rise of 6.53249574127815e+16 An angle of 90 degrees, or 1.5707963267949 radians, and run of 5 has a + rise of 8.16561967659768e+16 pi is 3.14159265358979 $ cat slope3.pl #!/usr/bin/perl -w use strict; use 5.010; BEGIN { push @INC, ".."; } use math1; use Math::Trig; my @slope = (0.0, 5.0, 8.0, 11.0, 14.0, 30.0, 90.0); say "slopes are @slope"; my @run = (2.25, 3.25, 4, 5); say "runs are @run"; foreach my $var1 (@slope) { my $s = degrees_to_radians($var1); foreach my $var2 (@run) { my $t = $var2 * tan($s); say "An angle of $var1 degrees, or $s radians, and run of $var2 has +a rise of $t"; } } my $a = pi(); say "pi is $a"; __END__ $
I made this as quick and dirty as I had to to get results. I like the results partially, in that I believe they're correct. The aspiration to have my own module was admirable for its valor, but not with its merits. I figured out that what I was doing came within spitting distance of *literally* re-inventing the circle.
$ cat math1.pm package math1; require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw( pi degrees_to_radians); sub pi{ use 5.010; use Math::Trig ':pi'; my $a = pi; return $a; } sub degrees_to_radians{ use 5.010; use Math::Trig qw(deg2rad); my $a = shift; my $b = deg2rad($a); return $b; } 1; $
I'm still fishing for people's experience with this, but I'll post a cleaned-up version of this that relies on cpan properly, instead of wrapping the calls and confusing perl.exe. Thanks all for comments.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: enumerating values for slopes
by Laurent_R (Canon) on Sep 22, 2014 at 06:15 UTC | |
by Aldebaran (Curate) on Sep 23, 2014 at 05:04 UTC | |
by Laurent_R (Canon) on Sep 23, 2014 at 17:36 UTC | |
by farang (Chaplain) on Sep 24, 2014 at 02:07 UTC | |
by Laurent_R (Canon) on Sep 24, 2014 at 06:59 UTC | |
by Aldebaran (Curate) on Sep 24, 2014 at 06:30 UTC | |
by Laurent_R (Canon) on Sep 23, 2014 at 06:11 UTC | |
by Aldebaran (Curate) on Sep 23, 2014 at 07:10 UTC | |
by Aldebaran (Curate) on Sep 23, 2014 at 06:40 UTC |