5 ms·
> The canned list processing functions can be implemented with a for loop. So? They abstract out common patterns. You could write the great majority of functio
by kbp 9y ago
> The canned list processing functions can be implemented with a for loop.
So? They abstract out common patterns. You could write the great majority of functions' implementations inline instead of calling them.
- crimsonalucard 9y agoSo if the implementation of a HO function is a for loop then then an HO function and a for loop are equivalent. Thus proving my original point: It's the same thing. Using HO functions in an imperative language is not much different from using a for loop, it's all sugar.
- kbp 9y agoIs that news to anyone? Sussman and Steele showed that tail recursive functions are equivalent to for loops over 40 years ago. Map, reduce, et al can be built on top of either of them, and they're just as useful built on top of either. They're factoring out common patterns, the same way printf, strlen, and memcpy do.
- crimsonalucard 9y agoApparently this concept is not even believed by the majority of people on this thread if you read the whole thing. I originally stated that for loops and HO functions are equivalent and this entire thread consists of people disputing that statement. You're the one dude telling me that what I'm saying is old news and totally obvious. I'm not sure if you realize it, but we're on the same side. As a side note, the equivalency between recursion and for loops is not limited to tail recursion. Recursion itself in all computing languages is implemented using a stack. So all recursion is equivalent to a for loop + a stack. This has been long known ever since programming languages utilized something called a call stack.
- kbp 9y ago> Apparently this concept is not even believed by the majority of people on this thread if you read the whole thing. > I originally stated that for loops and HO functions are equivalent and this entire thread consists of people disputing that statement. My read of the thread is that your posts seem to be going beyond saying they're functionally equivalent, and saying that there's no value in using reduce and friends because they're functionally equivalent. Most of your posts aren't addressing that tail recursion is a form of iteration (yes, or alternately that recursion can be done without a lexically recursive function) and that map/reduce/etc can be implemented in terms of recursion or for loops; you're contrasting the HOF's with for loops like they're competitors. The HOF's are an abstraction over iteration, whatever syntax was used to write that iteration. Most of the responses aren't disputing that they accomplish the same thing, they're just saying that there is value in using the HOF's. You would be getting the same kinds of replies if you were insisting there's no difference between HOF's and direct recursion. > You're the one dude I'm not a dude.
- crimsonalucard 9y agoI never said there's no value. I quote myself: > it's just a bit cooler or convenient to use map in place of a for >Most of your posts aren't addressing that tail recursion is a form of iteration (yes, or alternately that recursion can be done without a lexically recursive function) Why should I address this? This is not the main point. Even recursion without a tail can be considered a form of iteration. But how is this the topic of conversation? We are talking about the equivalency between HOFs and loops. Why are you bringing up the fixed point combinator? >you're contrasting the HOF's with for loops like they're competitors. The HOF's are an abstraction over iteration, whatever syntax was used to write that iteration. No I'm not! Not at all! I'm saying HOFs and LOOPS are ultimately the same thing!!! and thus when you use them in code you are not ultimately changing the paradigm of your programming to functional. The overall structure of your program is still imperative. >You would be getting the same kinds of replies if you were insisting there's no difference between HOF's and direct recursion. There's not much of a difference, I quote again: >> it's just a bit cooler or convenient to use map in place of ...
- 9y ago