Consider the following function definitions:

var split = function (pivot,ns) {
    return split_helper(pivot,ns,[ ],[ ]);
};

var split_helper = function (pivot,ns,smalls,bigs)  {
    if (fp.isNull(ns)) {
         return fp.cons(smalls,fp.cons(bigs,[ ]));
    } else if (fp.isLT(fp.hd(ns),pivot)) {
         return split_helper(pivot,fp.tl(ns),
                             fp.cons(fp.hd(ns),smalls),bigs);
    } else {
         return split_helper(pivot,fp.tl(ns),
                             smalls,fp.cons(fp.hd(ns),bigs));
    }
};

var join = function (ms,ns) {
    if (fp.isNull(ms)) {
        return ns;
    } else {
        return fp.cons(fp.hd(ms),join(fp.tl(ms),ns));
    }
};

The join function, in which both ms and ns are (flat) lists, is one that we have not yet discussed. What is the value of the following call to join?

  join(fp.hd(split(5,[1,9,2,8,3,7])),
       fp.hd(fp.tl(split(5,[1,9,2,8,3,7]))))
[ 3, 2, 1, 7, 8, 9 ]
  • [ 1, 2, 3, 9, 8, 7 ]
  • [ [1, 2, 3], [9, 8, 7] ]
  • [ [3, 2, 1], [7, 8, 9] ]

Make sure to review how the split_helper function works.

Note that the split function is being called twice with the same argument list.

Since the join function is being introduced for the first time in this exercise, make sure to understand its behavior fully, paying special attention to the order of the elements in its output.