Add Pair and Triple classes with zip functions#7
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds tuple classes (Pair and Triple) and zip functionality to the stdlib. These classes represent generic containers for two or three values respectively, following value semantics. The implementation includes comprehensive test coverage and documentation.
- Implements
Pair<A, B>andTriple<A, B, C>classes withtoList()andtoString()methods - Adds
zip()function to combine two arrays into pairs with optional transform function - Adds
zipWithNext()function to create pairs of adjacent elements with optional transform function
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/stdlib/common/tuples/Pair.ts | Implements generic Pair class with constructor, toList(), and toString() methods |
| src/stdlib/common/tuples/Triple.ts | Implements generic Triple class with constructor, toList(), and toString() methods |
| src/stdlib/collections/zip.ts | Implements zip function with overloads for default and transform behavior |
| src/stdlib/collections/zipWithNext.ts | Implements zipWithNext function with overloads for adjacent element pairing |
| src/stdlib/common/repeat.ts | Utility function for repeating an action n times |
| src/stdlib/common/index.ts | Exports Pair and Triple classes |
| src/stdlib/collections/index.ts | Exports zip and zipWithNext functions |
| docs/*.md | Documentation for the new classes and functions |
| docs/.vitepress/config.mts | Updates navigation to include new API documentation |
Comments suppressed due to low confidence (1)
src/stdlib/common/repeat.ts:8
- The repeat function is not mentioned in the PR description and appears unrelated to the Pair/Triple/zip functionality. This new function lacks context for why it was added and may need its own dedicated tests or removal if it's not intended for this PR.
export function repeat(times: number, action: (index: number) => void) {
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Features
PairandTripleclasses.zip()andzipWithNext()functions.