Skip to content

builtins: add uniqby keyed dedup (tree-only HOF)#195

Merged
danieljohnmorris merged 1 commit into
mainfrom
fix/uniqby-builtin
May 12, 2026
Merged

builtins: add uniqby keyed dedup (tree-only HOF)#195
danieljohnmorris merged 1 commit into
mainfrom
fix/uniqby-builtin

Conversation

@danieljohnmorris
Copy link
Copy Markdown
Collaborator

uniq did raw equality dedup. uniqby dedupes by a derived key, keeping the first occurrence per key. Critical for record-shaped lists where the equality you care about is on one field.

Implementation:

  • tree-only HOF, verifier enforces function literal in fn position
  • interpreter evaluates fn per element, tracks seen keys in a hash set
  • preserves input order

Tests: cross-engine regression tests + examples/uniqby.ilo with -- run: directives.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
3469 2 3467 0
View the top 2 failed test(s) by shortest run time
ilo::regression_uniqby::uniqby_basic_dedup_by_key_tree
Stack Traces | 0.009s run time
thread 'uniqby_basic_dedup_by_key_tree' (18993) panicked at tests/regression_uniqby.rs:66:5:
assertion `left == right` failed
  left: "[\"apple\"]"
 right: "[apple, banana, cherry]"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
ilo::regression_uniqby::uniqby_all_same_key_keeps_first_tree
Stack Traces | 0.012s run time
thread 'uniqby_all_same_key_keeps_first_tree' (18995) panicked at tests/regression_uniqby.rs:88:5:
assertion `left == right` failed
  left: "[\"alpha\"]"
 right: "[alpha]"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@danieljohnmorris danieljohnmorris force-pushed the fix/uniqby-builtin branch 3 times, most recently from 9f76b48 to 7b484f1 Compare May 12, 2026 09:55
uniq already existed for raw equality dedup. uniqby fn xs dedupes
by a derived key, keeping the first occurrence per key. Critical
for record-shaped lists where the equality you care about is on
one field, not the whole row.

Tree-only HOF: verifier enforces function literal in fn position,
interpreter evaluates per element, tracks seen keys in a hash set.
@danieljohnmorris danieljohnmorris merged commit 5c861e3 into main May 12, 2026
2 of 4 checks passed
@danieljohnmorris danieljohnmorris deleted the fix/uniqby-builtin branch May 12, 2026 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant