Home > front end >  Haskell beginner trying to find the syntax errors
Haskell beginner trying to find the syntax errors

Time:01-22

N = a ’div’ length xs
    where
      a = 10
     xs = [1,2,3,4,5]

I am currently learning Haskell and I got a task in which I have to find the syntax errors and try to fix them. I can see div needs to be enclosed with backquotes. However, I am not sure if there are any other errors?

CodePudding user response:

There are three problems here:

  1. you use an apostrophe [wiki] instead of backticks ` [wiki];
  2. you need to indent a and xs on the same column; and
  3. the name of functions starts with a lowercase, so n instead of N:
--               
  •  Tags:  
  • Related