[Haskell-begin] Fwd: Something simple

Rafael Gustavo da Cunha Pereira Pinto rafaelgcpp at gmail.com
Thu Jul 17 12:40:01 EDT 2008


You may want to take a look at the Random library to do that.
Random number generation depends (somewhat) on a state monad.



---------- Forwarded message ----------
From: Chad Wilson <chadrwilson at gmail.com>
Date: Thu, Jul 17, 2008 at 12:56
Subject: Something simple
To: beginners at haskell.org

I am a gamer.  Table top RPGs, war games, board games, etc.  Since my laptop
is pen-based, I has been handier to keep it at the table than paper.  As a
result, I have been experimenting with making dice rollers to have yet
another item not needed on the table.  Sure, it takes away some of the
tradition, but it makes for carrying fewer things.  I have written various
dice roll simulators in xblite, ruby and some other dynamics, but this seems
like an interesting exercise to try in Haskell.

My first goal is to figure out how to get the command-line arguments.  As I
did with the other languages, my first program in this development simply
retrieved the arguments and printed them.  So, here it is.

import System.Environment

main = do
  args <- getArgs
  print args

Very simple and to the point.  Now I need to dig into the manual and figure
out the next simple progression...taking 2 arguments and doing something to
them akin to:

roll 1 6

This would roll 1, 6-sided die, or 1d6 in gamer terms and print the result.

I figure the best way to learn a new language is to apply it something I
might actually use it for.

Chad Wilson

Beginners mailing list
Beginners at haskell.org

Rafael Gustavo da Cunha Pereira Pinto
Electronic Engineer, MSc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20080717/f09d9452/attachment.htm

More information about the Beginners mailing list