GuobaGuoba Utils

zip

@guoba-ai/utils / array / zip

Function: zip()

Call Signature

function zip<A, B>(a, b): [A, B][];

Defined in: array.ts:354

Combine multiple arrays element-wise into an array of tuples. The resulting length equals the shortest input array.

Type Parameters

A

A

B

B

Parameters

a

A[]

The first array

b

B[]

The second array

Returns

[A, B][]

An array of tuples combining elements at each index

Example

zip([1, 2], ['a', 'b']) // [[1, 'a'], [2, 'b']]
zip([1, 2, 3], ['a', 'b']) // [[1, 'a'], [2, 'b']]

Call Signature

function zip<A, B, C>(
   a, 
   b, 
   c): [A, B, C][];

Defined in: array.ts:355

Combine multiple arrays element-wise into an array of tuples. The resulting length equals the shortest input array.

Type Parameters

A

A

B

B

C

C

Parameters

a

A[]

The first array

b

B[]

The second array

c

C[]

Returns

[A, B, C][]

An array of tuples combining elements at each index

Example

zip([1, 2], ['a', 'b']) // [[1, 'a'], [2, 'b']]
zip([1, 2, 3], ['a', 'b']) // [[1, 'a'], [2, 'b']]

Call Signature

function zip(...arrays): unknown[][];

Defined in: array.ts:356

Combine multiple arrays element-wise into an array of tuples. The resulting length equals the shortest input array.

Parameters

arrays

...unknown[][]

Returns

unknown[][]

An array of tuples combining elements at each index

Example

zip([1, 2], ['a', 'b']) // [[1, 'a'], [2, 'b']]
zip([1, 2, 3], ['a', 'b']) // [[1, 'a'], [2, 'b']]

On this page