Talk:Haskell/Solutions/Recursion

CAVEAT Needed

A caveat is needed on the last block of solutions that warns readers that the code will not compile because of ambiguity between the code in the solution and that in Prelude.

Other recursive functions


This is no good to a learner (like myself) &mdash; the solution for the log2 problem:

log2 1 = 0 log2 n = 1 + log2 (n `div` 2) -- the "`" make div into infix notation

Ok, so when was I supposed to have read about `div` and infix notation? The central challenge to the problem should be thinking about a recursive definition of a logarithm, but instead it turns out to be a trick question about syntax that hasn't been discussed yet, and isn't discussed now.

I had written the right function definition, but had no idea about `div` until coming here after wasting a bunch of time trying to figure out how to use "/", silly me.

What does that explanation even mean? It's frustrating, and uninformative. I understand it's an 'advanced' question, but it's only advanced because it asks about stuff I would have no way of knowing, unless I just peek back here.

trainman261: not only that exercise, but in a later exercise '_' is used. There is no prior explanation as to what that is and what it can be used for.

Other recursive patterns: Exercises
As far as I can tell, these are out of sync with the exercise in the main section. In [], the recursive multiplication function checks if m is 0, whereas in the solution, the function seems to check if m is 1. As I a new to Haskell, though, I am leaving this here, as I am not 100% sure if I am right.