> There where at least two other replies talking about accumulators. I call that pattern, like it or not.
It's true that you use this way of programming so often in functional languages that it earned itself a name, so that it's easier to talk about it. However calling it a 'pattern' feels weird (to me), even though it technically is one.
The equivalent of accumulators in imperative languages would be the 'pattern' of having some variables outside of the loop and mutating them from within the loop. Maybe you can appreciate that it feels weird calling this a 'pattern' — and now you can better understand how I feel about accumulators being called a pattern.
Skipping back to your original question: I write Haskell for living and teach two high-school classes in another functional language, and the only two 'patterns' regarding recursion I can think of are accumulators and mutual recursion. So, you know almost everything there is to know already! :-) [0]
Let me add that you use recursion very rarely in day-to-day programming; mostly you try to spare yourself writing the recursion explicitly and you instead use map, filter and foldr/foldl (sometimes called reduce) to do the recursion for you. Especially the folds are super-powerful (AFAIK you can write any recursive function using folds, should you wish to do so), and often under-appreciated.
> Haskell is a genius language but I don't like the community
IMHO the community around Haskell is (in general) great; the people are always eager to help. I'm a self-learned Haskeller and I couldn't have done it without the community. Come join us at r/haskell or the IRC and see for yourself :-)
[0]: Why do I say this? I remember my old days when I was learning Swift and encountered one new design pattern every day. Factory, Facade, ... I decided to get 'em all (why reinvent the wheel?), I was always anxious that I was coding something that could be better served by a ready-made design pattern. So I just wanted to let you know it's nothing like this with recursion, and that you can save yourself the anxiety (if you are anything like me).
Hey thanks for the nice reply. I know you can't generalize like that. There are probably a lot friendly Haskellers around ;)
I was just angry when I wrote my last comment, because I had to read this:
>> as a special case of most people are idiots
which is so low in multiple ways. It's also just wrong, because by definition most people have average intelligence. Even if you think this is true, a smart person would not use it as an argument^^
It's on my todo-list to dive a bit into haskell, when I find time.
> It's true that you use this way of programming so often in functional languages that it earned itself a name, so that it's easier to talk about it. However calling it a 'pattern' feels weird (to me), even though it technically is one.
> The equivalent of accumulators in imperative languages would be the 'pattern' of having some variables outside of the loop and mutating them from within the loop. Maybe you can appreciate that it feels weird calling this a 'pattern' — and now you can better understand how I feel about accumulators being called a pattern.
That's a fair point, actually. I read "patterns" as "design patterns" a la the book of same name, based on the implied^Wlater stated title "accumulator pattern", but I agree it does fit a weaker notion of "pattern" such as "less-than-maximally-entropic (aka compressible in the information-theoretic sense) feature of code".
There where at least two other replies talking about accumulators. I call that pattern, like it or not.
Have you even heard of programming patterns?
> If we assume most imperative programmers are idiots as a special case of most people are idiots, sure.
The other reply from chongli seems to disagree with you ;)
Also suggesting that I'm stupid is no constructive style of argumentation.
> rather than that it wasn't a good/intuitive example to illustrate recursion
You are still misunderstanding me but a genius like you are should be able to figure that out.
I now understand what my teacher meant when he said:
"Haskell is a genius language but I don't like the community,"