2 ms·
Which is more generic, the 'for' or the 'map'? I think its the 'for' because it has additional capabilities contained in the base concept, which is why I would
by StillBored 7y ago
Which is more generic, the 'for' or the 'map'? I think its the 'for' because it has additional capabilities contained in the base concept, which is why I would call it more "fundamental".
In fact in many languages much of filter() can be implemented in the for construct rather than its body.
- kinjba11 7y agoThere are two sorts of 'fundamental'. You are correct that the 'for' is just syntactic sugar for 'goto' which is more fundamental than map/filter in the sense that it translates into assembly/machine language, upon which all programs are built. Then you can say the silicon logic gates are even more fundamental, you can do even more things with them, etc. The map/filter is more fundamental in a mathematical sense. If you turn a list of A turned into a list of A*, the 'mapping' is the fundamental concept, the 'for' loop is just an implementation detail. Maybe the computer did it in parallel, or in random order, or I asked you to turn a pile of towels into a folded stack of towels. The same way if I say 'want to watch a movie' - the movie the fundamental concept, whether it's digital, film, etc. is irrelevant.