code: function groupBy(f, xs) {
      const groups = [];
      for (const x of xs) {
          if (groups.length !== 0 && f(groups[groups.length - 1][0], x)) {
              groups[groups.length - 1].push(x);
          }
          else {
              groups.push([x]);
          }
      }
      return groups;
  }
docs: Splits an array based on the equivalence relation.
  The concatenation of the result is equal to the argument.