Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^3: Regarding the polynomial evaluation. Stuck at one part. please helpppp!!

by tmharish (Friar)
on Jan 22, 2013 at 15:09 UTC ( #1014687=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Regarding the polynomial evaluation. Stuck at one part. please helpppp!!
in thread Calculating polynomials and pushing them into an array. Stuck at one part. please helpppp!!

You are missing a bracket:

-0.137 + (0.00479 / (W/0.9)) + (2.5593 * (W/0.9 ) ,0.045,0 -0.137 + (0.00479 / (W/0.9)) + (2.5593 * (W/0.9 ) <---- HERE ,0.045,0

I still dont understand how this works - but it does!

Update: Including testing code that ( I am not sure how ) works!

use strict ; use warnings ; sub EvalPolynominal{ #first parameter gives the polynominal string #second parameter gives the min-des width #third parameter gives the short-line length my $polynominal=shift; my $curWidth=shift; my $curLength=shift; $polynominal =~ s/W/$curWidth/g ;#replace W with current value of ++min width $polynominal =~ s/L/$curLength/g ;#replace L with current value of ++ min Length my $result ; eval( $result = $polynominal ) ; # print "$result\n"; -- PRINTS THE STRING return eval ($polynominal); # Returns '0.086765' - WHY? } my $one = EvalPolynominal( '-0.137 + (0.00479 / (W/0.9)) + (2.5593 * ( +W/0.9 ))' ,0.045,0 ); print "$one\n";


Comment on Re^3: Regarding the polynomial evaluation. Stuck at one part. please helpppp!!
Select or Download Code
Re^4: Regarding the polynomial evaluation. Stuck at one part. please helpppp!!
by freekngeek (Acolyte) on Jan 22, 2013 at 15:47 UTC

    Thanks a lot man, It worked. So stupid of me, couldn't see that thing. I was missing a bracket. Your code worked because of the 2 brackets at the end of the equation and I was missing that one. It happened when I parsed the text into the array and I did something wrong. Thanks again

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1014687]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2014-12-17 23:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (40 votes), past polls