wanna_code_perl has asked for the wisdom of the Perl Monks concerning the following question:
Thanks for all the replies. Here's a bit more information to answer (some) of your questions and comments:
This is not (really) a code factorization problem. Sure, purists will say "but, you can factor anything into a sub!", and basically rewrite Mathematica, but that would be a bit extreme for my purposes.
It's also not that I keep writing very similar half-life routines, or acceleration routines, or "which brand/size of cola is the cheapest", whatever... it's more the meta issues of how to represent units (and convert, automatically, when you take something like 9.8 m/s/s * 1 hour, how fast am I going?) By themselves, most of these things are simple, but en masse, and in combination, they're still "simple", but inelegant in Perl (or most any other general purpose language for that matter).
moritz and others, helped me decide that what I want is indeed probably a full symbolic math engine. It's either that or "factor" every formula and snippet I use into something that I'd probably end up being tempted writing a symbolic parser for anyway, which would be silly.
Original post follows.
Hello monks,
Over and over, I find myself writing little Perl scripts to do relatively simple calculations (but usually too many steps to be reasonable for a conventional calculator or spreadsheet). Management (and conversion) of units would be very important. Short of using a dedicated math language like Mathematica (or one of the free ones), is there anything in between, so I can still take advantage of Perl syntax for output, loops, CPAN modules, etc.?
Just one example of something I'd calculate would be various properties of the Half-life of a substance. Using the usual formulae, I'd want to calculate how much of the substance is left after N days (given a half life in hours), and then, given regular input of more substance, how long to reach a steady state. I won't bore you with the math, here; it's not especially difficult. See the above link for more information.
Writing pure Perl for this isn't difficult, but it is tedious and repetitive, especially given management of different units and conversions between.
My apologies for the rather vague specification of what I'm looking for, but that's part of the problem: I've thought about this more than once, and don't have a clear idea, aside from hiring a college student. :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Simple algebraic calculations
by moritz (Cardinal) on Apr 18, 2014 at 19:56 UTC | |
by wanna_code_perl (Friar) on Apr 19, 2014 at 16:19 UTC | |
|
Re: Simple algebraic calculations
by roboticus (Chancellor) on Apr 18, 2014 at 18:12 UTC | |
|
Re: Simple algebraic calculations
by kcott (Archbishop) on Apr 18, 2014 at 23:51 UTC | |
|
Re: Simple algebraic calculations
by Laurent_R (Canon) on Apr 19, 2014 at 09:54 UTC | |
|
Re: Simple algebraic calculations
by soonix (Chancellor) on Apr 19, 2014 at 03:40 UTC | |
|
Re: Simple algebraic calculations
by flexvault (Monsignor) on Apr 19, 2014 at 15:05 UTC | |
|
Re: Simple algebraic calculations
by NetWallah (Canon) on Apr 18, 2014 at 22:51 UTC | |
|
Re: Simple algebraic calculations
by Laurent_R (Canon) on Apr 18, 2014 at 21:29 UTC |