Requires the Hack Standard Library to be installed.
Facebook Engineer?

This function is available as Keyset\partition() in Facebook's www repository.

Returns a 2-tuple containing keysets for which the given predicate returned true and false, respectively

namespace HH\Lib\Keyset;

function partition<Tv as arraykey>(
  Traversable<Tv> $traversable,
  (function(Tv): bool) $predicate,
): (keyset<Tv>, keyset<Tv>);

Time complexity: O(n * p), where p is the complexity of $predicate Space complexity: O(n)



  • (keyset<Tv>, keyset<Tv>)