0

I am writing a function that maps lists of lists of bools invectively into lists of bools. This is my code:

y=[False| y<-[0..]]    
encode :: [[Bool]] -> [Bool]
encode x:xs =   (zip1 x y):True:True:(encode xs)
encode []=[]

The zip1 function just takes two lists and writes them alternating into a new list.

I'm getting the error message

Parse error in pattern: encode

Why do I get this error message?

2
  • 1
    it's probably just encode (x:xs) Commented May 8, 2016 at 18:05
  • Possible duplicate of Haskell: Parse error in pattern Commented Sep 6, 2017 at 8:02

1 Answer 1

5

Function application has higher precedence than :

Thus, Haskell parses

encode x:xs 

as

(encode x):xs 

which makes no sense. You need

encode (x:xs) 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.