I have a Haskell file which looks like this:
longest::[Integer]->[Integer]->[Integer]
max a b = if length a > length b then a else b
llfs::[Integer]->Integer
llfs li = length(foldl longest group(li))
llfs([1, 2, 3, 3, 4, 5, 1, 1, 1])
Which should print out the result of the function call at the end, however when I run the file I get this error:
parse error (possibly incorrect indentation)
I don t understand what I m doing wrong. What should I do to fix it?
Edit
After putting the last line inside the main function, like this:
import List
longest::[Integer]->[Integer]->[Integer]
longest a b = if length a > length b then a else b
llfs::[Integer]->Integer
llfs li = length(foldl longest group(li))
main = print (llfs [1, 2, 3, 3, 4, 5, 1, 1, 1])
I now get the following error:
C:UsersMartinDesktopHaskellQ1.hs:7:31:
Couldn t match expected type `[Integer]
against inferred type `[a] -> [[a]]
In the second argument of `foldl , namely `group
In the first argument of `length , namely
`(foldl longest group (li))
In the expression: length (foldl longest group (li))
This one looks a little more difficult! How do I solve it?