Skip to content

builtins: add zip xs ys for pairing two lists#187

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

builtins: add zip xs ys for pairing two lists#187
danieljohnmorris merged 1 commit into
mainfrom
fix/zip-builtin

Conversation

@danieljohnmorris
Copy link
Copy Markdown
Collaborator

Pairing two lists element-wise was a missing primitive. Without it, users hand-rolled map + at + range, which is verbose for a one-token idiom.

Implementation:

  • builtin zip xs ys returns list of two-element lists
  • truncates to the shorter input
  • opcode allocated for zip, wired through interpreter and cranelift VM

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

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

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

Files with missing lines Patch % Lines
src/verify.rs 27.27% 24 Missing ⚠️
src/interpreter/mod.rs 54.54% 10 Missing ⚠️
src/vm/compile_cranelift.rs 20.00% 8 Missing ⚠️
src/vm/mod.rs 87.03% 7 Missing ⚠️

📢 Thoughts on this report? Let us know!

@danieljohnmorris danieljohnmorris force-pushed the fix/zip-builtin branch 2 times, most recently from 796189b to fdac734 Compare May 12, 2026 09:21
Pairing two lists element-wise was a missing primitive. Producing
[[x0,y0],[x1,y1],...] forced users to map + at + idx ranges, which
is verbose for what is a one-token idiom in every other language.

Opcode allocated: zip. Truncates to the shorter input. Works on any
list type pair, returning a list of two-element lists.
@danieljohnmorris danieljohnmorris merged commit 0501459 into main May 12, 2026
4 of 5 checks passed
@danieljohnmorris danieljohnmorris deleted the fix/zip-builtin branch May 12, 2026 09:36
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