HH\Lib\Vec\concat

Meta Engineer?

This is available as Vec\concat in the www repository.

Returns a new vec formed by concatenating the given Traversables together

namespace HH\Lib\Vec;

function concat<Tv>(
  Traversable<Tv> $first,
  Container<Tv> ...$rest,
): vec<Tv>;

For a variable number of Traversables, see Vec\flatten().

Time complexity: O(n + m), where n is the size of $first and m is the combined size of all the ...$rest Space complexity: O(n + m), where n is the size of $first and m is the combined size of all the ...$rest

Parameters

Returns

  • vec<Tv>

Examples

$original_vec = vec["abc", "def", "ghi"];
$rest = vec["xxx", "yyy"];
$concat_vec = Vec\concat($original_vec, $rest);
echo "Resulting concat vec: \n";
\print_r($concat_vec);
//Output: Resulting concat vec: 
//vec["abc", "def", "ghi", "xxx", "yyy"]