My code:
addConcat :: [Int] -> [Int]
addConcat [x,y] = z:(z + y) where (z = x + y)
I'm implementing a function not exactly the one above but it's of the same format and I always get:
Syntax error in input (unexpected symbol "y")
So what is wrong with my Haskell code? I really need to use the 'where' clause but I think I'm doing something wrong.
I cannot reproduce the error you claim you get. If you are writing that code into a file and compiling it with
ghcthe error is:And the problem is that the syntax for
whereis wrong. Either write:Or you have to use curly braces:
You cannot use parenthesis to group an assignment.
Note that when writing in ghci you must group together the declarations and use a
letto define functions:Note also that even fixing this your function still has a type error because the second argument of
:must be a list whilez+yis a number. You wantz:[z+y]or more simply[z, z+y].