Hi,
so I'm a newbie getting used to Haskell. I'm writing some
simple things like genetic algorithms in it for practice,
and I keep coming across something that really bugs me:
are there any standard libraries that allow you to
do imperative style for or while loops using monads to keep
Creighton Hogg wrote:
Hi,
so I'm a newbie getting used to Haskell. I'm writing some
simple things like genetic algorithms in it for practice,
and I keep coming across something that really bugs me:
are there any standard libraries that allow you to
do imperative style for or while loops
Try this:
This line is before the loop
sequence_ $ replicate 10 $ do
line 1
line 2
...
last line
This line is after the loop
Now you can use shorthand via
loopN n block = sequence_ $ replicate n block
So that you can write:
This line is before the loop
loopN 10 $ do
line 1
line 2
On Oct 27, 2005, at 11:54 AM, Creighton Hogg wrote:
Hi,
so I'm a newbie getting used to Haskell. I'm writing some
simple things like genetic algorithms in it for practice,
and I keep coming across something that really bugs me:
are there any standard libraries that allow you to
do imperative
Creighton Hogg wrote:
Hi,
so I'm a newbie getting used to Haskell. I'm writing some
simple things like genetic algorithms in it for practice,
and I keep coming across something that really bugs me:
are there any standard libraries that allow you to
do imperative style for or while loops
On Thu, 27 Oct 2005, Creighton Hogg wrote:
On Thu, 27 Oct 2005, Robert Dockins wrote:
On Oct 27, 2005, at 11:54 AM, Creighton Hogg wrote:
Hi,
so I'm a newbie getting used to Haskell. I'm writing some
simple things like genetic algorithms in it for practice,
and I keep
Hello Creighton,
Thursday, October 27, 2005, 7:54:22 PM, you wrote:
CH Haskell seems to me to be a very powerful language, and it
CH looks like it should be possible to define control
CH structures such as for loops using monads.
it's my own lib:
-- |Conditional execution
whenM cond action =