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
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]
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
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
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
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
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
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
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
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
10 matches
Mail list logo