Re: devices without division

2011-04-20 Thread Kenneth Wolcott
On Wed, Apr 20, 2011 at 03:58, Saran wrote: > Here is the program > > use strict; > use warnings; > > my ($div,$reminder) = ÷_now(20,4); > print "Dividend: $div\nReminder: $reminder\n"; > > sub divide_now { >        my ($a,$b) = @_; > >        my ($s,$n); >        for($n=1;;$n++) { >              

Re: devices without division

2011-04-20 Thread Brian Fraser
On Wed, Apr 20, 2011 at 7:58 AM, Saran wrote: > Here is the program > > use strict; > use warnings; > > my ($div,$reminder) = ÷_now(20,4); Please don't call subs with &; It'll bite you in the arse eventually. You can read why in perldoc perlsub[0], or well, this mailing list. Brian. [0] htt

Re: devices without division

2011-04-20 Thread Saran
Here is the program use strict; use warnings; my ($div,$reminder) = ÷_now(20,4); print "Dividend: $div\nReminder: $reminder\n"; sub divide_now { my ($a,$b) = @_; my ($s,$n); for($n=1;;$n++) { $d+=$b; $s = $a - ($n*$b); retu

Re: devices without division

2011-04-20 Thread Jenda Krynicky
> How to write a device funciton without using a '/' operator > > sub device_now($a, $b){ > my ($a, $b)=@; > > > > return $result; > > } > &device_now(6,3); That's "divide", not "device". Not sure it's the solution that the professor had in mind, but you can use exponentiation (in Pe

devices without division

2011-04-19 Thread ai nguyen
Hi there, How to write a device funciton without using a '/' operator sub device_now($a, $b){ my ($a, $b)=@; return $result; } &device_now(6,3); -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/