Variable not in scope
sara_n (2)

For every piece of code that I wrote, I get ''variable not in scope''. (for example :
length1 :: [a] -> Int
length1 l | l==[] =0
| otherwise = 1 + length1 tail l
some of the other solutions i tried are written by my teaher.

You are viewing a single comment. View All
ThatSmart (86)

For one, you don't need that trailing parenthesis. Second, you need to add some parentheses because function calling has high precedence. Third, you need to add a type constraint for A if you are going to check if it's empty in this way. Also, I'd implement this with a foldl.

ThatSmart (86)

@ThatSmart Let me know if you need more help.