1
$\begingroup$

I am working on a homework assignment to create a function and it says to use a "pure recursive approach". I am trying to piece together what is actually meant by this. I am aware a recursive function calls it self, usually by reducing until it hits a base case and a pure function is basically a function that does not change the variable values.

I assume all that is meant by "pure recursive approach" is to use recursion that does not change the original values of the parameters out side of the function. Is there something I'm missing?

$\endgroup$

closed as unclear what you're asking by David Richerby, Evil, Juho, Rick Decker, Gilles Mar 9 '17 at 12:48

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 6
    $\begingroup$ Have you tried asking your instructor or teaching assistant? It sounds like you're asking us to guess what they might be thinking, but we have even less context than you do to guess what they might be thinking. $\endgroup$ – D.W. Feb 28 '17 at 8:47
  • 1
    $\begingroup$ I can't be 100% sure, since I did not attend your course, but I believe you are reading too much in that expression. It seems the instructor is simply saying "just use recursion, do not use much else". If your language has mutation/loops avoid those. Pattern matching, pair projections, constructors (e.g. for lists) are OK. $\endgroup$ – chi Feb 28 '17 at 13:58
  • $\begingroup$ My guess is that “pure recursive” means “don't use any mutable variables, and so you can't have any useful loops, and so the only way to do non-trivial things is to do recursion”. But this isn't universally-agreed-on terminology so you should ask your instructor to clarify. $\endgroup$ – Gilles Mar 9 '17 at 12:49