HH\Lib\Vec\range

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

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

Returns a new vec containing the range of numbers from $start to $end inclusive, with the step between elements being $step if provided, or 1 by default

namespace HH\Lib\Vec;

function range<Tv as num>(
  Tv $start,
  Tv $end,
  ?Tv $step = NULL,
): vec<Tv>;

If $start > $end, it returns a descending range instead of an empty one.

Time complexity: O(n), where n is the size of the resulting vec Space complexity: O(n), where n is the size of the resulting vec

Parameters

  • Tv $start
  • Tv $end
  • ?Tv $step = NULL

Returns

  • vec<Tv>