Haskell beginner trying to find the syntax errors
There are many errors in the code:
N = a ’div’ length xs
where
a = 10
xs = [1,2,3,4,5]
-
div
needs to be enclosed in backquotes. -
xs
in line 4 needs to be aligned witha
in order to say that it is part of the same code block - Function names in Haskell must start with a lower case letter
There are three problems here:
- you use an apostrophe
’
[wiki] instead of backticks`
[wiki]; - you need to indent
a
andxs
on the same column; and - the name of functions starts with a lowercase, so
n
instead ofN
:
-- 🖟 🖟 backticks
n = a `div` length xs
where
a = 10
xs = [1,2,3,4,5] -- 🖘 same indentation as a