Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Converting pascal code to perl

by Necos (Friar)
on Aug 15, 2002 at 09:39 UTC ( [id://190349]=note: print w/replies, xml ) Need Help??


in reply to Converting pascal code to perl

How about we combine all of the answers given and try this:
# perl -w; use strict; sub roll1 { return ((0,1,2,3,4,5,6)[abs(6-abs($_[0]-7))])/36; } print roll1($_),$/ for (2..12);
I checked this out on my Win32 machine and it produces:

C:\>perl pascal.pl
0.0277777777777778
0.0555555555555556
0.0833333333333333
0.111111111111111
0.138888888888889
0.166666666666667
0.138888888888889
0.111111111111111
0.0833333333333333
0.0555555555555556
0.0277777777777778

just like everyone elses code. Hope that helps some...

Theodore Charles III
Network Administrator
Los Angeles Senior High
4650 W. Olympic Blvd.
Los Angeles, CA 90019
323-937-3210 ext. 224
email->secon_kun@hotmail.com
perl -e "map{print++$_}split//,Mdbnr;"

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-16 15:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found