Length of lists within list of lists?

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-lists-within-list-of-lists--tp28203363p28203... Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

You need a method that will find the length of a list:
length :: [a] -> Int
and a method that will applies a function to every element of a list
and make a list of the results:
map :: (a ->b) -> [a] -> [b]
Try and put them together.
hth,
-deech
On 4/10/10, 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-lists-within-list-of-lists--tp28203363p28203... Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

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 that can do this? thanks
-- View this message in context: http://old.nabble.com/Length-of-lists-within-list-of-lists--tp28203363p28203... Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

someMethod :: [[a]] -> [Int] someMethod = map length There's a list, haskell-beginners better suited for this kind of question. Alex On Saturday 10 April 2010 18:02:37 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 that can do this? thanks
participants (3)
-
aditya siram
-
Alexandru Scvortov
-
boblettoj