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