3 * Copyright (c) 2004-present, Facebook, Inc.
6 * This source code is licensed under the MIT license found in the
7 * LICENSE file in the root directory of this source tree.
13 use namespace HH\Lib\
{C
, Math
};
16 * Returns a new vec formed by concatenating the given Traversables together.
18 * For a variable number of Traversables, see `Vec\flatten()`.
20 * Time complexity: O(n + m), where n is the size of `$first` and m is the
21 * combined size of all the `...$rest`
22 * Space complexity: O(n + m), where n is the size of `$first` and m is the
23 * combined size of all the `...$rest`
26 Traversable
<Tv
> $first,
27 Container
<Tv
> ...$rest
29 $result = cast_clear_legacy_array_mark($first);
30 foreach ($rest as $traversable) {
31 foreach ($traversable as $value) {
39 * Returns a vec where each element is a tuple (pair) that combines, pairwise,
40 * the elements of the two given Traversables.
42 * If the Traversables are not of equal length, the result will have
43 * the same number of elements as the shortest Traversable.
44 * Elements of the longer Traversable after the length of the shorter one
47 * Time complexity: O(min(m, n)), where m is the size of `$first` and n is the
49 * Space complexity: O(min(m, n)), where m is the size of `$first` and n is the
52 <<__ProvenanceSkipFrame
>>
54 Traversable
<Tv
> $first,
55 Traversable
<Tu
> $second,
57 $one = cast_clear_legacy_array_mark($first);
58 $two = cast_clear_legacy_array_mark($second);
60 $lesser_count = Math\
minva(C\
count($one), C\
count($two));
61 for ($i = 0; $i < $lesser_count; ++
$i) {
62 $result[] = tuple($one[$i], $two[$i]);