25 ms·
Perhaps it is just me but I have a degree in CS, programmed in c for 10 years then C# for 10 years an I can't follow anything about that article claiming recurs
by uberman 2y ago
Perhaps it is just me but I have a degree in CS, programmed in c for 10 years then C# for 10 years an I can't follow anything about that article claiming recursion is simple.
(* n (* n (expt n (p-1))) etc...
huhhh?
and yes, I can do recursion.
- gorjusborg 2y agoI didn't even look at the examples, but I knew the author had to be a lisper. People get so used to patterns of thought, they forget what they had to do to get there.
- gus_massa 2y agoIt looks like scheme. Anyway, that unindented code hurts my eyes. (It's not as bad as an unmatched parenthesis, but it's close.)
- andy99 2y agoYes that's my take too. Once you know something well, it's easy to formulate it elegantly to say it's nothing more than the monoid in the category of endofunctors or whatever, but how something is conceptualized by those who get it has no bearing on how it's learned. A lot of the time, it seems like lots of worked examples without any theory is the way to go until something clicks. All that said, I can't understand why someone would find recursion complicated which probably means I'm unsuitable to teach it.
- rachofsunshine 2y agoThis is Polish notation [1], which puts a symbol for the function at the front of a term and the arguments of that function after it. So (* 2 3) is what you'd usually write as 2*3. So you can read this code: (define (expt n p) (if (equals? p 1) n (* n (expt n (- p 1))) As this more typical psuedocode function expt(n,p): if p = 1: return n return n * exp(n, p-1) Or the more mathematical framing: n^p = n * n^(p-1) [1] https://en.wikipedia.org/wiki/Polish_notation https://en.wikipedia.org/wiki/Polish_notation
- im3w1l 2y agoShouldn't it be p-2, too?