The function achieves its purpose, like all other functions presented in this chapter, not by modifying the original list but by creating a new one having the desired characteristic.
Remark: This is a trademark of functional programming, providing a higher robustness compared to programs causing side effects, i.e. programs that destructively modify data. Functional programs are also easier to verify and eventually to debug than so called imperative programs.
A++ supports all three major programming paradigms but in this chapter the functional programming style is exclusively applied and generally preferred to the others. Banning the other programming styles generally would not be appropriate, because the object oriented paradigm is not only popular but also very useful and the imperative programming style cannot not be avoided entirely.