-1

I am getting a parse error after I changed this:

h :: ([Int],Int,[Int])->[[Int]]

h ([],k,x) =[[]]

h(y:[],k,x) = [x++k:[y]]

h(y:xs,k,x)= [x++k:y:xs]++h(xs,k,x++[y])

to this: at line 3

h :: [Int]->Int->[Int]->[[Int]]

h [] k x  =[[]]

h (y:[]) k x = [x++k:[y]]

h y:xs k x = [x++k:y:xs]++h(xs,k,x++[y])
Chris Martin
  • 30,334
  • 10
  • 78
  • 137
SambaBoy
  • 3
  • 1

1 Answers1

3

There are two problems with this line:

h y:xs k x = [x++k:y:xs]++h(xs,k,x++[y])
  ^^^^                    ^^^^^^^^^^^^^
  (1)                     (2)
  1. You need parens around this pattern - (y:xs)
  2. Unlike in other languages like C, Java, C#, etc, in Haskell you don't use commas to separate parameters to functions.
Chris Martin
  • 30,334
  • 10
  • 78
  • 137
ErikR
  • 51,541
  • 9
  • 73
  • 124
  • Correct me if I'm wrong, please. I'd like to add that in the expression `h (y:[]) k x`, `(y:[])` is expected to be a tuple `([Int],Int,[Int])` by declaration of `h`. In `h y:xs k x` then `y` is expected to be such a tuple. – TobiMcNamobi Sep 06 '17 at 08:01