> Now, in this case, this is a silly operation, since foldr (:) [] is just a complicated identity function on lists, but we could imagine a slightly more complicated function, such as one that doubles each element in a list.
This whole post is great, but this part would be less awkward and easier to understand with a simpler example of more practical use like:
To spell things out a bit more:
A list is fundamentally constructed from [] and :. In the sense that a list is either empty [] or a head : tail, where tail is another list.
One might write 1:2:3:4:[].
foldr is deciding where to map [] and :. So for example:
This is a way better explanation than the cryptic:
" it (foldr) takes the second argument and the last item of
the list and applies the function, then it takes the
penultimate item from the end and the result, and so on.
See scanr for intermediate results. "
This whole post is great, but this part would be less awkward and easier to understand with a simpler example of more practical use like:
or x && y doesn't evaluate y if x is False.