Showing posts with label RPN. Show all posts
Showing posts with label RPN. Show all posts

Wednesday, May 12, 2010

Jr. High Math - Perl to the rescue

My daughter needed a calculator to check square roots last night.  I couldn't believe it - we didn't have one!  Well, I had my beloved HP 15C from engineering school days.  RPN is cool - right?!  Yeah, you can imagine how that went over.  So, then I grabbed a slide rule.  I know!  You guessed it - worse reaction than RPN.  So then I grabbed her Dell netbook, which was running Ubuntu Linux , and wrote a Perl hack that was basically

   #!/usr/bin/perl
   print "Enter a number\n";
   $number = stdin;
   chomp $number;
   $root = sqrt $number;
   print "The square root of $number is $root\n";

Ha!  It worked and she used it.  Perl to the rescue!