
16 Jan
2021
16 Jan
'21
5:10 p.m.
I have this myLength1 = foldl (\n _ -> n + 1) 0 and this myLength2 = foldr (\_ n -> n + 1) 0 I am guessing that foldl knows to assign the accumulator-seed argument to the dependent variable and the list argument's elements recursively to the independent variable; and with foldr to do the opposite. Is this a fair assumption? BTW, where can I get a look at the code for fold functions; or does the type definition answer my original question? Not really able to decipher it so well :t foldl foldl :: Foldable t => (b -> a -> b) -> b -> t a -> b LB