What is wrong with this list comprehension code?

Posted by suresh on Stack Overflow See other posts from Stack Overflow or by suresh
Published on 2012-03-26T22:20:08Z Indexed on 2012/03/26 23:30 UTC
Read the original article Hit count: 199

Filed under:

My aim is to list all elements of the array a whose values are greater than their index positions. I wrote a Haskell code like this.

[a|i<-[0..2],a<-[1..3],a!!i>i]

When tested on ghci prelude prompt, I get the following error message which I am unable to understand.

No instance for (Num [a]) arising from the literal 3 at <interactive>:1:20 Possible fix: add an instance declaration for (Num [a])

© Stack Overflow or respective owner

Related posts about haskell