Zip
提出詳細
type Zip<T, U, _A extends unknown[] = []> = T extends [infer T1, ...infer TRest] ? U extends [infer U1, ...infer URest] ? Zip<TRest, URest, [..._A, [T1, U1]]> : _A : _A
提出日時 | 2024-09-11 12:14:33 |
---|---|
問題 | Zip |
ユーザー | ookkoouu |
ステータス | Accepted |
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<Zip<[], []>, []>>, Expect<Equal<Zip<[1, 2], [true, false]>, [[1, true], [2, false]]>>, Expect<Equal<Zip<[1, 2, 3], ['1', '2']>, [[1, '1'], [2, '2']]>>, Expect<Equal<Zip<[], [1, 2, 3]>, []>>, Expect<Equal<Zip<[[1, 2]], [3]>, [[[1, 2], 3]]>>, ]