I would like to understand a code which is a recursive function with this kind of structure f[x_, y_] := {f[x], f[y]}. This case is present in the XMLNote function used in the help for “Transforming XML”.
I have already spent time on the help to look for more about recursive functions. But, I have seen only recursive functions such as Pise[0] = Pise[1] = 1; Pise[n_] := Pise[n - 1] + Pise[n - 2] . In this case, I understand how the indentation is made that is to say how the term of index n is calculated from the terms of index n-1 and n-2.
But, for this kind of recursive function f[x_, y_] := {f[x], f[y]}, i don’t understand how the indentation is made.
May you complete me this example/ or furnish me a small example so that I can see how this kind of recursion works ?
The function you’ve provided is not refering to itself basing on values of arguments that were provided but basing on the pattern that those arguments match*.
p.s. you probably wanted to write:
f[x_, y_]:= {f[x], f[y]}
So f refers to itself only when you provide two arguments. Then it is returning itself scanned over those arguments. And since for f acting on one argument are no associated values the recursion stops.
Yes, i almost understand. Thank you for your clear explanation.
I only need to apply it on a simple example
When i evaluate f[2, 3], the result is {f[2], f[3]}. Logically, the recursive function stops because each function has only one argument.
But I evaluate f[{2, 3}, {3, 3}], the result is {f[{2, 3}], f[{3, 3}]}. I would like to Mathematica continue the indentation. I believe that it becomes i didn’t use the syntax of the list well.
May you help me to correct my syntax so that I can test this kind of recursive function on a example ?