One thing that I just now understood tripped me up was looking at this definition (foldl f z [] = z), looking back at the diagram and then doing a double-take (wait, that can't be right? how did z get down there?).
Of course, that's because I forgot that z here is just the parameter to that fold case, and not necessarily the z you pass in when you call fold on a list.
One thing that I just now understood tripped me up was looking at this definition (foldl f z [] = z), looking back at the diagram and then doing a double-take (wait, that can't be right? how did z get down there?).
ReplyDeleteOf course, that's because I forgot that z here is just the parameter to that fold case, and not necessarily the z you pass in when you call fold on a list.