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
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
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.
___
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
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
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.
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
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 [
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
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 (
10 matches
Mail list logo