I am writing a function to find the intersection between two sets.
The non-functional requirements of the assignment include avoiding "side effects".
function intersection(a, b) { return helper(a, b, []); } function helper(a, b, c) { if (a.length == 0) { return c; } if (b.contains(a[0])) { return helper(a.slice(1, a.length), b, c.concat([a[0]])); } return helper(a.slice(1, a.length), b, c); } Would mutating the argument c in the above code be considered a side effect?
The specific assignment is written in OCaml, so, though the above example is in an imperative language, I want to stay true to the spirit of functional programming.
Please don't provide any alternate solutions to the problem.