Back to Type Challenges

README

questions/04499-medium-chunk/README.md

latest1.4 KB
Original Source
<!--info-header-start--><h1>Chunk </h1><blockquote><p>by キリサメ qianxi <a href="https://github.com/qianxi0410" target="_blank">@qianxi0410</a></p></blockquote><p><a href="https://tsch.js.org/4499/play" target="_blank"></a> </p><!--info-header-end-->

Do you know lodash? Chunk is a very useful function in it, now let's implement it. Chunk<T, N> accepts two required type parameters, the T must be a tuple, and the N must be an integer >=1

ts
type exp1 = Chunk<[1, 2, 3], 2> // expected to be [[1, 2], [3]]
type exp2 = Chunk<[1, 2, 3], 4> // expected to be [[1, 2, 3]]
type exp3 = Chunk<[1, 2, 3], 1> // expected to be [[1], [2], [3]]
<!--info-footer-start-->

<a href="../../README.md" target="_blank"></a> <a href="https://tsch.js.org/4499/answer" target="_blank"></a> <a href="https://tsch.js.org/4499/solutions" target="_blank"></a> <!--info-footer-end-->