Aldebaran has asked for the wisdom of the Perl Monks concerning the following question:
Hello monks,
I'm in the middle of a window project, and it's the part where I'm supposed to make the field measurements to determine the slope of the sill. It's a tricky measurement with significant consequences, and I want to have a list of values to judge from. I typically do this type of thing in fortran, but this just isn't working for me in a variety of ways. There probably isn't anything wrong with it, it's just that I need to have more flexibility, so that I can see the values under differing assumptions. The fortran program I want to replace follows
$ gfortran -Wall -Wextra -o out marvin1.f90 marvin1.f90:4.36: real :: rise, run, theta, deg_to_rad, rad, pi 1 Warning: Unused variable 'deg_to_rad' declared at (1) $ ./out pi is 3.14159274 rise is 0.421622515 $ cat marvin1.f90 program main implicit none real :: rise, run, theta, deg_to_rad, rad, pi run = 3.0 theta = 8.0 pi = 4.0*atan(1.0) print *,"pi is", pi rad = theta * pi / 180.0 rise = run * tan (rad) print *, "rise is ", rise end program main ! gfortran -Wall -Wextra -o out marvin1.f90 $
The perl replacement will have a list of values for runs, a list of values for rises, and it will calculate all the permutations and list them in order. This is my modest achievement so far. The values are carefully chosen for this very task:
$ perl slope1.pl slopes are 0 5 8 11 14 30 90 runs are 2.25 3.25 4 5 $ cat slope1.pl #!/usr/bin/perl -w use strict; use 5.010; 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"; __END__ $
One of the reasons I usually revert to fortran is that I don't want to have to re-think getting numbers like pi right. So it is that I will have a math module for perl that will give me pi and degrees_to_radians at the end of this thread. I think there's a lot of ways to achieve these results and was fishing for methods and people's experience with the same material.
My question then is: how do I solve this problem using perl, whilst generating a *robust* module that will never have me starting from scratch again like this (famous last words)?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: enumerating values for slopes
by trippledubs (Deacon) on Sep 21, 2014 at 06:06 UTC | |
by Laurent_R (Canon) on Sep 21, 2014 at 09:57 UTC | |
by Anonymous Monk on Sep 21, 2014 at 10:15 UTC | |
by Laurent_R (Canon) on Sep 21, 2014 at 10:34 UTC | |
by Aldebaran (Curate) on Sep 22, 2014 at 03:39 UTC | |
|
Re: enumerating values for slopes
by BrowserUk (Patriarch) on Sep 21, 2014 at 12:25 UTC | |
by Aldebaran (Curate) on Sep 22, 2014 at 03:31 UTC | |
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 Laurent_R (Canon) on Sep 23, 2014 at 06:11 UTC | |
| |
by Aldebaran (Curate) on Sep 23, 2014 at 06:40 UTC |