/**
 * Partions an array into two using `partitionFn`. If `partitionFn`
 * returns `true`, the element is placed into the left array.
 *
 * @param {array} array
 * @param {function} partitionFn
 */
function partition(array, partitionFn) {
  return array.reduce(
    ([left, right], elem) => {
      return partitionFn(elem)
        ? [[...left, elem], right]
        : [left, [...right, elem]]
    },
    [[], []]
  )
}

export default partition