Re: [Haskell-cafe] Length of lists within list of lists?

2010-04-10 Thread boblettoj
Ah yes of course, thankyou! boblettoj wrote: > > Hi i want to know if there is any method i can use to count the number of > items in each list in a list of lists, eg. > > someMethod [[a, b, c], [a], [b, d, e, f]] > would return [3, 1, 4] > > is there anything th

[Haskell-cafe] Length of lists within list of lists?

2010-04-10 Thread boblettoj
Hi i want to know if there is any method i can use to count the number of items in each list in a list of lists, eg. someMethod [[a, b, c], [a], [b, d, e, f]] would return [3, 1, 4] is there anything that can do this? thanks -- View this message in context: http://old.nabble.com/Length-of-lis

Re: [Haskell-cafe] Occurs check error, help!

2010-03-21 Thread boblettoj
Haha, much better now! Thanks for all your help, it's working great! -- View this message in context: http://old.nabble.com/Occurs-check-error%2C-help%21-tp27966341p27975606.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___

Re: [Haskell-cafe] Occurs check error, help!

2010-03-20 Thread boblettoj
newStdGen results in IO Ints whereas i need normal Ints and it seems theres no easy way to convert them without a lot more knowledge of haskell. I have tried using a where clause instead of using do but this is giving me the occurs check error again! --function used to shuffle cards --list equal

Re: [Haskell-cafe] Occurs check error, help!

2010-03-20 Thread boblettoj
I was using a do loop to try and create a generator before using it in the randomR call, is there a better way to do this? randoms and randomRs return lists whereas i just want a single number. thanks -- View this message in context: http://old.nabble.com/Occurs-check-error%2C-help%21-tp27966341

Re: [Haskell-cafe] Occurs check error, help!

2010-03-20 Thread boblettoj
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.

Re: [Haskell-cafe] Occurs check error, help!

2010-03-20 Thread boblettoj
Oh yeh, how silly. How do i create a generator to use in that function call then? i've tried using a do like this: shuffle i cards = do gen <- mkStdGen 10 return ([(cards!!i) : (shuffle (randomR (0, ((length cards)-2)) gen) (delete (cards!!i) cards))]) but that gives me

Re: [Haskell-cafe] Occurs check error, help!

2010-03-20 Thread boblettoj
Ah yes, that makes sense now, however i have another problem, here is the updated code: --function used to shuffle cards --list equals random member of array plus the rest of the array --i is randomly generated from range of length equal to that of cards. shuffle :: Int -> [a] -> [a] shuffle i [

[Haskell-cafe] Occurs check error, help!

2010-03-20 Thread boblettoj
Hi i am writing a shuffle function which takes in a random number i and a list and then produces a jumbled up version of the list at the end. Here is what i have at the moment (i'm not sure if it works yet as it won't compile! --function used to shuffle cards --list equals random member of array

[Haskell-cafe] First time haskell - parse error!

2010-03-09 Thread boblettoj
Hi, i am getting an error when trying to compile this part of my program, its my first time using haskell and as lovely as it is it didn't give me very much to go on in the error message! score :: String -> String -> String score [s] [] = false score [s] [g] = if valid 4 g then (