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)?


In reply to enumerating values for slopes by Aldebaran

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.