Consider the following definition of the function subst:
var subst = function (n,o,ns) { if (fp.isNull(ns)) { return [ ]; } else if (fp.isEq(o,fp.hd(ns))) { return fp.cons(n,subst(n,o,fp.tl(ns))); } else { return fp.cons(fp.hd(ns),subst(n,o,fp.tl(ns))); } }
Suppose that you want to make this function perform a "deep substitution" at all levels of a (generalized) list. For example:
> subst( 2, 3, [3, 9, [4, 2, 3], 3, 5] ) [ 2, 9, [ 4, 2, 2 ], 2, 5 ]
Which one of the following statements best characterizes how this could be done?
Remember that, on an exam or if called upon in class, you will have to fully develop the code for this function.