Excerpts from Bryan O'Sullivan's message of Wed Oct 07 23:25:10 +0200 2009:
> On Wed, Oct 7, 2009 at 1:59 PM, Michael Mossey wrote:
>
> > My thread about randomness got hijacked so I need to restate my remaining
> > question here. Is it acceptable to write pure routines that use but do not
> > ret
On Wed, Oct 7, 2009 at 2:28 PM, Michael Mossey wrote:
> I don't quite follow your response. I want a program that initializes the
> generator from the global generator because I want different behavior every
> time I run it. So it will need IO. That's what I was trying to demonstrate.
> And I was
Am Mittwoch 07 Oktober 2009 23:28:59 schrieb Michael Mossey:
> Luke Palmer wrote:
> > On Wed, Oct 7, 2009 at 2:59 PM, Michael Mossey
> > wrote:
> >> My thread about randomness got hijacked so I need to restate my
> >> remaining question here. Is it acceptable to write pure routines that
> >> use
Luke Palmer wrote:
On Wed, Oct 7, 2009 at 2:59 PM, Michael Mossey wrote:
My thread about randomness got hijacked so I need to restate my remaining
question here. Is it acceptable to write pure routines that use but do not
return generators, and then call several of them from an IO monad with
On Wed, Oct 7, 2009 at 1:59 PM, Michael Mossey wrote:
> My thread about randomness got hijacked so I need to restate my remaining
> question here. Is it acceptable to write pure routines that use but do not
> return generators, and then call several of them from an IO monad with a
> generator obta
On Wed, Oct 7, 2009 at 2:59 PM, Michael Mossey wrote:
> My thread about randomness got hijacked so I need to restate my remaining
> question here. Is it acceptable to write pure routines that use but do not
> return generators, and then call several of them from an IO monad with a
> generator obta
My thread about randomness got hijacked so I need to restate my remaining
question here. Is it acceptable to write pure routines that use but do not
return generators, and then call several of them from an IO monad with a
generator obtained by several calls to newStdGen?
shuffle :: RandomGen g
Iain Barnett wrote:
On 24 Sep 2008, at 10:13 pm, Evan Laforge wrote:
> For one approach, check
> out 'replicate' to make copies of something, and then 'sequence' to
> run them and return a list.
>
Thanks, I haven't found anything that explains 'sequence' well yet, but
I'll keep looking.
Yet
> And the one liner:
> (rand 1 10) >>= return . (\v -> take v [1..10])
What about:
take <$> rand 1 10 <*> pure [1..10]
(more readable IMHO).
One could even define:
f <%> x = f <*> pure x
and have
take <$> rand 1 10 <%> [1..10]
Also, why not using getRandomR(1,10) instead?
take <$
On 2008 Sep 24, at 17:44, Iain Barnett wrote:
On 24 Sep 2008, at 10:13 pm, Evan Laforge wrote:
For one approach, check
out 'replicate' to make copies of something, and then 'sequence' to
run them and return a list.
Thanks, I haven't found anything that explains 'sequence' well yet,
but I'll
On Wed, 2008-09-24 at 22:44 +0100, Iain Barnett wrote:
> On 24 Sep 2008, at 10:13 pm, Evan Laforge wrote:
> > For one approach, check
> > out 'replicate' to make copies of something, and then 'sequence' to
> > run them and return a list.
> Thanks, I haven't found anything that explains 'sequence'
On Wed, 24 Sep 2008, Iain Barnett wrote:
On 24 Sep 2008, at 10:13 pm, Evan Laforge wrote:
For one approach, check
out 'replicate' to make copies of something, and then 'sequence' to
run them and return a list.
Thanks, I haven't found anything that explains 'sequence' well yet, but I'll
kee
On 24 Sep 2008, at 10:13 pm, Evan Laforge wrote:
For one approach, check
out 'replicate' to make copies of something, and then 'sequence' to
run them and return a list.
Thanks, I haven't found anything that explains 'sequence' well yet,
but I'll keep looking.
On 24 Sep 2008, at 10:13 pm,
On Wed, 24 Sep 2008, Iain Barnett wrote:
Hi,
I have a function, that produces a random number between two given numbers
rand :: Int -> Int -> IO Int
rand low high = getStdRandom (randomR (low,high))
If you only need arbitrary numbers, not really random ones, you should
stay away from IO:
Your forgetfulness boosted my ego for a few seconds - I wasn't the
only one! :)
Thanks very much, that's a big help.
Iain
On 24 Sep 2008, at 10:10 pm, Lev Walkin wrote:
forgot return, of course:
> myTake :: IO [Int]
> myTake = do
> n <- rand 1 10
> return $ take n [1..10]
Lev Wa
And the one liner:
(rand 1 10) >>= return . (\v -> take v [1..10])
On Wed, Sep 24, 2008 at 5:10 PM, Lev Walkin <[EMAIL PROTECTED]> wrote:
> forgot return, of course:
>
> > myTake :: IO [Int]
> > myTake = do
> > n <- rand 1 10
> > return $ take n [1..10]
>
>
> Lev Walkin wrote:
>
>> Iain B
On Wed, Sep 24, 2008 at 2:03 PM, Iain Barnett <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have a function, that produces a random number between two given numbers
>
> rand :: Int -> Int -> IO Int
> rand low high = getStdRandom (randomR (low,high))
>
>
> (Naively) I'd like to write something like
>
> tak
forgot return, of course:
> myTake :: IO [Int]
> myTake = do
> n <- rand 1 10
> return $ take n [1..10]
Lev Walkin wrote:
Iain Barnett wrote:
Hi,
I have a function, that produces a random number between two given
numbers
rand :: Int -> Int -> IO Int
rand low high = getStdRandom (r
Iain Barnett wrote:
Hi,
I have a function, that produces a random number between two given numbers
rand :: Int -> Int -> IO Int
rand low high = getStdRandom (randomR (low,high))
(Naively) I'd like to write something like
take (rand 1 10 ) [1..10]
and see [1,2,3,4] ... or anything but nasty
Hi,
I have a function, that produces a random number between two given
numbers
rand :: Int -> Int -> IO Int
rand low high = getStdRandom (randomR (low,high))
(Naively) I'd like to write something like
take (rand 1 10 ) [1..10]
and see [1,2,3,4] ... or anything but nasty type-error message
20 matches
Mail list logo