HH\Lib\Dict\partition

Meta Engineer?

This is available as Dict\partition in the www repository.

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

namespace HH\Lib\Dict;

function partition<Tk as arraykey, Tv>(
  KeyedTraversable<Tk, Tv> $traversable,
  (function(Tv): bool) $predicate,
): (dict<Tk, Tv>, dict<Tk, Tv>);

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

Parameters

Returns

  • (dict<Tk, Tv>, dict<Tk, Tv>)