Re: [Haskell-cafe] Re: Random question

2008-10-07 Thread Iain Barnett
On 5 Oct 2008, at 7:06 pm, Henning Thielemann wrote: Instead of separate calls to 'take' and 'drop' you may prefer 'splitAt': requeue z xs = let (prefix,pivot:suffix) = splitAt (z-1) xs in prefix ++ suffix ++ [pivot] Thanks. Took me a while to get the function to shuffle

Re: [Haskell-cafe] Re: Random question

2008-10-07 Thread Brent Yorgey
On Tue, Oct 07, 2008 at 06:40:22PM +0100, Iain Barnett wrote: On 5 Oct 2008, at 7:06 pm, Henning Thielemann wrote: Instead of separate calls to 'take' and 'drop' you may prefer 'splitAt': requeue z xs = let (prefix,pivot:suffix) = splitAt (z-1) xs in prefix ++ suffix ++ [pivot]

[Haskell-cafe] Re: Random question

2008-10-05 Thread Iain Barnett
I just wanted to say thanks to everyone that helped me on this. I'm still reading/cogitating the stuff you gave me, but I did manage to write a Fisher-Yates shuffle using random numbers. I had a lightbulb moment while reading about sequence (so I suppose that might count as my 7th Monad

Re: [Haskell-cafe] Re: Random question

2008-10-05 Thread Henning Thielemann
On Sun, 5 Oct 2008, Iain Barnett wrote: I just wanted to say thanks to everyone that helped me on this. I'm still reading/cogitating the stuff you gave me, but I did manage to write a Fisher-Yates shuffle using random numbers. I had a lightbulb moment while reading about sequence (so I

[Haskell-cafe] Re: Random question

2008-09-25 Thread Achim Schneider
Ariel J. Birnbaum [EMAIL PROTECTED] wrote: And the one liner: (rand 1 10) = return . (\v - take v [1..10]) What about: take $ rand 1 10 * pure [1..10] The reason why this doesn't work by default is the occurrence distribution of tutorials about warm, fuzzy things and warm, funky

[Haskell-cafe] A Random Question

2007-12-15 Thread Dominic Steinitz
I need to generate distinct arbitrary values for my quickcheck tests and they don't have to be arbitrary (although that doesn't matter). No problem I thought, I'll create my own random number generator (which will not be random at all) and use choose :: forall a. (Random a) = (a, a) - Gen a

[Haskell-cafe] A Random Question

2007-12-15 Thread Dominic Steinitz
What do you need, i.e., what meaning do you attribute to the words predictable and arbitrary? Apologies - I didn't explain my problem clearly. I want to say something like: instance Arbitrary Foo where arbitrary = choose (Foo 1, Foo 5) but the random values are generated by my own

Re: [Haskell-cafe] A Random Question

2007-12-15 Thread Paul Johnson
Dominic Steinitz wrote: I want to say something like: instance Arbitrary Foo where arbitrary = choose (Foo 1, Foo 5) but the random values are generated by my own random number generator not the standard one. Does that make sense? The reason I'm trying to do this is I am generating random

Re: [Haskell-cafe] A Random Question

2007-12-15 Thread Dominic Steinitz
Paul Johnson wrote: Dominic Steinitz wrote: Unfortunately for your purpose you would need: *generate* :: (RandomGen g) = Int http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-Int.html#t%3AInt - g - Gen

Re: [Haskell-cafe] A Random Question

2007-12-15 Thread Harald Holtmann
Dominic Steinitz schrieb: What do you need, i.e., what meaning do you attribute to the words predictable and arbitrary? Apologies - I didn't explain my problem clearly. I want to say something like: instance Arbitrary Foo where arbitrary = choose (Foo 1, Foo 5) but the random