Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Improve my coding

by jwkrahn (Abbot)
on Jun 13, 2009 at 03:35 UTC ( [id://771168]=note: print w/replies, xml ) Need Help??


in reply to Improve my coding

#!/usr/bin/perl use warnings; use strict; #3_3.pl #loop over drop radius from 1 micron to 100 microns in steps of 2 micr +ons #use each radius to compute cross section #if radius <20 microns, use (pi)*(r^2)*a*(1-exp(-c*r)) #if radius >= 20 microns, use 2*pi*(r^2) my @radii = grep $_ & 1, 1 .. 100; my $pi = atan2 0, -1; my $twopi = 2 * $pi; my $a0 = 1.18; my $c0 = 0.28e6; my ( @rads, @sigs ); foreach my $r ( @radii ) { push @rads, 1e-6 * $r; # push @sigs, $r > 20 ? $twopi * $rad ** 2 : $pi * $rad ** 2 * $a0 * + ( 1 - exp -$c0 * $rad ); # **Update: Oops, changed $rad to $rads[-1] push @sigs, $r > 20 ? $twopi * $rads[-1] ** 2 : $pi * $rads[-1] ** + 2 * $a0 * ( 1 - exp -$c0 * $rads[-1] ); } print "@rads\n"; print "@sigs\n";

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (11)
As of 2024-04-18 14:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found