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

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

Returns a new vec containing the first $n elements of the given Traversable

namespace HH\Lib\Vec;

function take<Tv>(
  Traversable<Tv> $traversable,
  int $n,
): vec<Tv>;

To drop the first $n elements, see Vec\drop().

Time complexity: O(n), where n is $n Space complexity: O(n), where n is $n



  • vec<Tv>