LESSON 35 OF 52 · CHAPTER 04
Vector Allocation
fill, len and sum on a three-element numerical vector
11-vector-allocation.srp
// The generated 3-element vector uses 24 payload bytes.
bind numbers = fill(1.0, 3);
print(sum(numbers), len(numbers));
stdout
3.0 3
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
fill, len and sum on a three-element numerical vector
Expected behavior
3.0 3
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.
तीन मानों वाला वेक्टर
fill(1.0, 3) तीन 1.0 मानों वाला संख्यात्मक वेक्टर बनाता है। sum उसका योग और len कुल मानों की संख्या देता है। स्रोत टिप्पणी में बताया गया बाइट-काउंट सामान्य मेमरी मैनेजमेंट API का वादा नहीं है।
आउटपुट: एक ही लाइन 3.0 3।
अभ्यास: कौन-सा फ़ंक्शन वेक्टर के मानों का योग निकालता है और कौन-सा उसकी लंबाई?
Explanations are sourced from the project's English chapter guide and हिन्दी अध्याय. The Scarp program and output are unchanged.
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/11-vector-allocation.srp
scarp exec examples/04-collections/11-vector-allocation.srpThe website does not run code. Read the CLI guide ↗
Pinned compiler: Scarp v0.0.6-alpha.3
· ceff07d9014f. No simulated output.