1 / 6 Settings
<<<>>>

Both subRt and append use a nearly identical pattern of computation. They apply an operation (i.e., fp.sub for subRt and fp.cons for append) to the head of the list and the result obtained from a recursive call on the tail of the list. This pattern is highlighted in red below.

  1. 1
  2. 3
  3. 2
l1
  1. 1
  2. 2
  3. 3
l2
  • var subRt = function (ns) {
  • if (fp.isNull(ns)) {
  • return 0;
  • } else {
  • return fp.sub(fp.hd(ns),
  • subRt(fp.tl(ns)));
  • }
  • };
  • subRt(l1)
  • subRt(l2)
  • var append = function (l1,l2) {
  • if (fp.isNull(l1)) {
  • return l2;
  • } else {
  • return fp.cons(fp.hd(l1),
  • append(fp.tl(l1), l2));
  • }
  • };
  • append(l1, l2);
Proficient Saving... Error Saving
Server Error
Resubmit