Skip to content

builtins: add frq xs for frequency maps with type-prefixed keys#210

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

builtins: add frq xs for frequency maps with type-prefixed keys#210
danieljohnmorris merged 1 commit into
mainfrom
fix/frq-builtin

Conversation

@danieljohnmorris
Copy link
Copy Markdown
Collaborator

Counting occurrences is one of the most common aggregations (word counts, label tallies, histograms). Doing it manually needs a verbose fold with map lookups.

Implementation:

  • frq xs returns M t n keyed by element with type-prefixed keys so n and s with the same printed form don't collide
  • Opcode 140 across tree, vm, cranelift

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

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

❌ Patch coverage is 78.53659% with 44 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/interpreter/mod.rs 56.25% 14 Missing ⚠️
src/vm/mod.rs 79.10% 14 Missing ⚠️
src/verify.rs 40.00% 9 Missing ⚠️
src/vm/compile_cranelift.rs 22.22% 7 Missing ⚠️

📢 Thoughts on this report? Let us know!

Counting occurrences is one of the most common aggregations agents do
(word counts, label tallies, histogram bucketing). Doing it manually
needs a fold with map lookups and writes, which is verbose.

frq xs returns M t n keyed by element with type-prefix encoding so n
and s elements with the same printed form don't collide. Opcode 140
across tree, vm, cranelift.
@danieljohnmorris danieljohnmorris merged commit 4fc509d into main May 12, 2026
4 of 5 checks passed
@danieljohnmorris danieljohnmorris deleted the fix/frq-builtin branch May 12, 2026 18:19
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