-
Notifications
You must be signed in to change notification settings - Fork 61
Add unique and pivot_table functions to BuiltinsList #2005
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #2005 +/- ##
==========================================
+ Coverage 49.78% 50.07% +0.28%
==========================================
Files 218 218
Lines 23103 23237 +134
==========================================
+ Hits 11502 11635 +133
- Misses 11601 11602 +1
🚀 New features to boost your workflow:
|
7132ac7 to
e875f5c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds two new convenience functions to the Hazel builtins library: unique (removes duplicate elements from a list) and pivot_table (reshapes data from long to wide format). Both functions are implemented as Hazel functions following the existing patterns in the codebase.
Key changes:
uniquefunction removes duplicates from a list while preserving orderpivot_tablefunction transforms tabular data by creating pivot tables with configurable row/column extractors and aggregation functions- Test cases added for both new functions
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/language/builtins/BuiltinsList.re | Adds unique and pivot_table function definitions with type signatures and implementations |
| test/evaluator/Test_Evaluator_Builtins_Lists.re | Adds test cases verifying the behavior of both new functions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| }, | ||
| }, | ||
| { | ||
| str: {hazel|fix pivot_table -> fun (table, new_col, index, value) -> |
Copilot
AI
Nov 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter order in the str field (table, new_col, index, value) does not match the order in the imp field at lines 3045-3049, which uses (table, new_col, index, value). However, the implementation appears to expect the parameters in the order (table, index, new_col, value) based on how they're used in the test (line 466-468: first extracts row, then column). Please verify the intended parameter order is consistent between the string representation and the implementation.
| str: {hazel|fix pivot_table -> fun (table, new_col, index, value) -> | |
| str: {hazel|fix pivot_table -> fun (table, index, new_col, value) -> |
Add a new builtin function `group_on_key` that groups list elements by a provided key function. This function takes a list and a key extractor, then accumulates groups by key using a recursive update helper, enabling efficient clustering of data based on computed keys. The implementation uses a fix point for the `update_groups` helper to handle membership checks and group accumulation iteratively. This enhances the language's builtin capabilities for data manipulation tasks.
Co-authored-by: Copilot <[email protected]>
Adds
uniqueandpivot_tablefunctions to the builtins context. These are implemented as Hazel functions and added for convenience.