Skip to content

builtins: add range a b for arithmetic sequences#208

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

builtins: add range a b for arithmetic sequences#208
danieljohnmorris merged 1 commit into
mainfrom
fix/range-builtin

Conversation

@danieljohnmorris
Copy link
Copy Markdown
Collaborator

Arithmetic sequences are bread-and-butter for agent tasks (iterating 0..n, axis ticks, index lists). Without a builtin, agents waste tokens on recursive unfolds.

Implementation:

  • range a b returns half-open integer L n, empty when a >= b
  • Opcode 138 across tree, vm, cranelift; 1M element cap

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

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

❌ Patch coverage is 76.03306% with 29 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 74.19% 8 Missing ⚠️
src/verify.rs 38.46% 8 Missing ⚠️
src/vm/compile_cranelift.rs 20.00% 8 Missing ⚠️
src/vm/mod.rs 90.74% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

Arithmetic sequences come up constantly in agent tasks (iterating 0..n,
generating axis ticks, building index lists). Without a builtin, agents
spend tokens on recursive constructors or unfold patterns. range a b
returns the half-open integer sequence [a, b) as L n, empty when a >= b.

Opcode 138 across tree, vm, cranelift. Cap at 1M elements to bound
allocations from a runaway agent.
@danieljohnmorris danieljohnmorris merged commit 0aa6adb into main May 12, 2026
4 of 5 checks passed
@danieljohnmorris danieljohnmorris deleted the fix/range-builtin branch May 12, 2026 21: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