I was trying to get the length of each element, given a nested list; and I also I want to get rid of the repeated length.
For example, a nested list [[1],[1,2],[4..5]]
should give me [1,2]
.
I can do it in the interactive by nub (map length [[1],[1,2],[4..5]])
. But if I write a file with the following code:
Import Data.List
getLen :: [[a]] ->[Int]
getLen xs = nub (map length xs)
I got the error saying:
"Parse error: naked expression at top level"
What does this error mean and how can I fix this?