Learning about folds in the context of boolean!

hello, I’m still a little confused about the types of arguments fold takes.

For example, in this boolean function that I made, I have a parse error that I can’t seem to fix.

Couple of notes:

  • False && a is False for any a
  • = is definition, not equality (==) (this is probably the most immediate source of the parse error)
  • foldr's arguments correspond to “recursion step”, “base case”, and “source of items”

With that last bit in mind, can you express and with only one pattern (i.e., without the explicit [] case)? What is the recursive step? Describe it, then try to write code corresponding to that description. What is the type of the recursive step, both in general (i.e., foldr's type signature) and what is the type of the recursive step for this case (substituting Bool)?

simply adding == doesn’t fix it either

Kaleb please try to include the errors.

If you do not include them it gets difficult to help you.

At least one other issue is that you’re using _ in a position where it’s not valid.

Again, return to the type. What does it tell you about the function you need to give to foldr? Would a function of one argument (\b -> ...) be a good fit there?

1 Like

you’re right I’m sorry

I need to keep practicing