so I\'m creating an function like this:
unlinhas::[String]->String
uninhas [x] = \"\"
unlinhas (x:xs) = x ++ \"\\n\" ++(unlinhas( xs))
th
Your first pattern [x]
is a list with one element. So the Haskell compiler is wondering what to do with an empty list.
Furthermore in your first line you write uninhas
, instead of unlinhas
, as a result the Haskell compiler thinks that you write two different functions.
Based on your specifications however, you want to process the empty list, so you can fix it with:
unlinhas:: [String] -> String
unlinhas [] = ""
unlinhas (x:xs) = x ++ "\n" ++(unlinhas( xs))
You can further cleanup the code, and write it as:
unlinhas:: [String] -> String
unlinhas [] = ""
unlinhas (x:xs) = x ++ '\n' : unlinhas xs