boblettoj <bobletto...@msn.com> writes:

> Yes sorry, that line should be indented, now it gives me a bigger error :(
> What that line is trying to achieve is return a list where the first element
> is the card at the given random number in the first list and the rest of the
> list should be fed back in to shuffle along with a new random number.
>
> shuffle :: Int -> [a] -> [a]
> shuffle i [] = []
> shuffle i cards = do
>       gen <- mkStdGen
>       return ([(cards!!i) : (shuffle (randomR (0, ((length cards)-2)) gen)
> (delete (cards!!i) cards))])

First of all, why are you using a do block?

Secondly, mkStdGen :: Int -> StdGen : you need to provide it with a
number and it doesn't return a monadic value, so you can't use <- with
it.

Thirdly, have a look at randoms and randomRs.

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to