Skip to content

builtins: add window n xs for sliding windows#213

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

builtins: add window n xs for sliding windows#213
danieljohnmorris merged 1 commit into
mainfrom
fix/window-builtin

Conversation

@danieljohnmorris
Copy link
Copy Markdown
Collaborator

Sliding windows are essential for moving averages, n-gram extraction, local feature detection, time-series smoothing. Hand-rolling needs nested indexing with bounds checks.

Implementation:

  • window n xs returns list of n-sized contiguous sublists
  • Empty when n > len(xs) or n < 1
  • Opcode 146 across tree, vm, cranelift

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

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

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

Files with missing lines Patch % Lines
src/vm/mod.rs 49.23% 33 Missing ⚠️
src/verify.rs 25.92% 20 Missing ⚠️
src/interpreter/mod.rs 67.74% 10 Missing ⚠️
src/vm/compile_cranelift.rs 20.00% 8 Missing ⚠️
src/vm/jit_cranelift.rs 20.00% 8 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sliding windows are essential for moving averages, n-gram extraction,
local feature detection, and any time-series smoothing. Hand-rolling
needs nested indexing and bounds checks, which is verbose and bug-prone
on short inputs.

window n xs returns a list of n-sized contiguous sublists. Empty when
n > len(xs) or n < 1. Opcode 146 across tree, vm, cranelift.
@danieljohnmorris danieljohnmorris merged commit 4f7bf2e into main May 12, 2026
4 of 5 checks passed
@danieljohnmorris danieljohnmorris deleted the fix/window-builtin branch May 12, 2026 22:05
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