HH\Lib\Vec\chunk

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

This function is available as Vec\chunk() in Facebook's www repository.

Returns a vec containing the original vec split into chunks of the given size

namespace HH\Lib\Vec;

function chunk<Tv>(
  Traversable<Tv> $traversable,
  int $size,
): vec<vec<Tv>>;

If the original vec doesn't divide evenly, the final chunk will be smaller.

Time complexity: O(n) Space complexity: O(n)

Parameters

Returns

  • vec<vec<Tv>>