itertools-ts icon indicating copy to clipboard operation
itertools-ts copied to clipboard

Implement transform.divide()

Open Smoren opened this issue 11 months ago • 10 comments

Divide the elements of the iterable evenly into n smaller iterables, maintaining order. Ex: ([1, 2, 3, 4], 2) => [1, 2], [3, 4]

function *divide<T>(data: Iterable<T> | Iterator<T>, n: number): Iterable<Array<T>>

Needs to be implemented:

  • transform.divide()
  • transform.divideAsync()
  • Stream.divide()
  • AsyncStream.divide()

Smoren avatar Feb 09 '25 12:02 Smoren

Hi @Smoren Can you assign this issue to me if the issue is still open?

DaBestCode avatar Aug 27 '25 21:08 DaBestCode

Hi @DaBestCode You're welcome!

Smoren avatar Aug 28 '25 06:08 Smoren

Hi @Smoren can you assign this to me or can I just work on it?

DaBestCode avatar Aug 29 '25 05:08 DaBestCode

Hi @DaBestCode! Done.

Smoren avatar Aug 30 '25 11:08 Smoren

Thanks @Smoren . I have started writing divide and divideAsync. I just need a clarification. Because the issue shows a *,should the function be a generator or a normal function?

DaBestCode avatar Aug 30 '25 22:08 DaBestCode

Hi @DaBestCode! All the functions must be generators.

Smoren avatar Aug 31 '25 13:08 Smoren

Hi @Smoren I have put up a PR with all the runs passing the test cases. So, is this issue closed?

DaBestCode avatar Sep 01 '25 20:09 DaBestCode

Hi @DaBestCode! I'll close this issue when the PR is merged.

Smoren avatar Sep 02 '25 18:09 Smoren

Hi @Smoren I have rebased and took care of the conflicts. I am done with the tests for transform/divide.test.ts. I believe I have to write tests for stream and async-stream too but I am not understanding where to write them can you guide me on this issue.

DaBestCode avatar Sep 06 '25 21:09 DaBestCode

Hi @DaBestCode

  • /tests/stream/transform.test.ts
  • /tests/async-stream/transform.test.ts

Smoren avatar Sep 07 '25 06:09 Smoren