LESSON 26 OF 52 · CHAPTER 04
Vector Windows
Selecting and combining numeric windows
02-vector-windows.srp
// Zero-copy selection and checked re-materialization from visible ranges.
bind values = [10.0, 20.0, 30.0, 40.0];
bind middle = window(values, 1, 2);
print(middle);
print(stitch(middle, [50.0]));
print(window(middle, 2, 0));
stdout
[20.0, 30.0]
[20.0, 30.0, 50.0]
[]
Write what you expect this program to print. Check prediction for a line-level hint without revealing the answer, or reveal the verified output when ready. This checks displayed text only; it does not run Scarp or save your input.
UNDERSTAND THE CODE
Explanation & practice
What this example teaches
Selecting and combining numeric windows
Expected behavior
[20.0, 30.0], [20.0, 30.0, 50.0], []
Practice: Read the source before looking at the output. Predict the values and their order, then use the pinned compiler to execute this lesson and compare the exact fixture. Identify which operation produces the result.
वेक्टर विंडो
window(values, 1, 2) दूसरे स्थान से दो मान चुनता है। stitch उसके साथ नया वेक्टर जोड़ता है। शून्य लंबाई की विंडो खाली है।
आउटपुट: [20.0, 30.0], फिर [20.0, 30.0, 50.0], फिर []।
अभ्यास: विंडो में 10.0 क्यों नहीं आया?
Explanations are sourced from the project's English chapter guide and हिन्दी अध्याय. The Scarp program and output are unchanged.
SOURCE-BACKED SELF-CHECK · स्रोत-आधारित अभ्यास
Quick checkpoint / त्वरित अभ्यास
Which values are printed for window(values, 1, 2)?window(values, 1, 2) के लिए कौन-से मान प्रिंट होते हैं?
Reveal the source-backed answer / सही उत्तर देखें
[20.0, 30.0] — Starting at index 1 selects the second and third values of [10.0, 20.0, 30.0, 40.0].[20.0, 30.0] — index 1 से शुरू करने पर [10.0, 20.0, 30.0, 40.0] में दूसरे और तीसरे मान चुने जाते हैं।
This question checks understanding of a recorded compiler output. It does not run Scarp in the browser. यह प्रश्न सत्यापित आउटपुट पर आधारित है; ब्राउज़र में Scarp नहीं चलता।
LEARNING PROGRESS
Keep your place
Mark this lesson complete when you are ready.
Only saved in this browser. No account or tracking.
TRY IT LOCALLY
Verify, then execute
Use the pinned compiler from the course root. Keep any imported _support files next to the source.
scarp verify examples/04-collections/02-vector-windows.srp
scarp exec examples/04-collections/02-vector-windows.srpThe website does not run code. Read the CLI guide ↗
Pinned compiler: Scarp v0.0.6-alpha.3
· ceff07d9014f. No simulated output.