Skip to content

builtins: add chunks n xs for non-overlapping splits#215

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

builtins: add chunks n xs for non-overlapping splits#215
danieljohnmorris merged 1 commit into
mainfrom
fix/chunks-builtin

Conversation

@danieljohnmorris
Copy link
Copy Markdown
Collaborator

Batching is everywhere (pagination, CSV groups, RPC batch sizing, parallel work splits). Hand-rolled index arithmetic gets the trailing partial chunk wrong.

Implementation:

  • chunks n xs returns non-overlapping n-sized sublists; final chunk may be shorter
  • Errors on n < 1; empty in empty out
  • Opcode 148 across tree, vm, cranelift

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

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

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

Files with missing lines Patch % Lines
src/verify.rs 25.92% 20 Missing ⚠️
src/interpreter/mod.rs 64.28% 10 Missing ⚠️
src/vm/compile_cranelift.rs 20.00% 8 Missing ⚠️
src/vm/mod.rs 89.83% 6 Missing ⚠️

📢 Thoughts on this report? Let us know!

Batching is everywhere (pagination, fixed-row CSV groups, RPC batch
sizing, parallel work splits). Without a builtin, agents write index
arithmetic by hand and bungle the trailing partial chunk.

chunks n xs returns non-overlapping n-sized sublists; the final chunk
may be shorter when len is not a multiple of n. Opcode 148 across
tree, vm, cranelift. Empty in empty out, errors on n < 1.
@danieljohnmorris danieljohnmorris merged commit 80ea3d3 into main May 12, 2026
4 of 5 checks passed
@danieljohnmorris danieljohnmorris deleted the fix/chunks-builtin branch May 12, 2026 22:12
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