code: function (xs, f) {
        if (xs.length === 0) {
          return [];
        } else {
          var wasType = f(xs[0]); // initial case for matching
          var r = [];
          var group = [];
  
          for (var i = 0, len = xs.length; i < len; i++) {
            var x = xs[i];
            var type = f(x);
            if (type !== wasType) {
              r.push(group);
              group = [];
            }
            wasType = type;
            group.push(x);
          }
          if (group.length !== 0) {
            r.push(group);
          }
          return r;
        }
      }
docs: /*
  Groups an array into contiguous arrays of like elements. Whether an element is like or not depends on f.
  
  f is a function that derives a value from an element - e.g. true or false, or a string.
  Elements are like if this function generates the same value for them (according to ===).
  
  
  Order of the elements is preserved. Arr.flatten() on the result will return the original list, as with Haskell groupBy function.
  For a good explanation, see the group function (which is a special case of groupBy)
  http://hackage.haskell.org/package/base-4.7.0.0/docs/Data-List.html#v:group