CHAPTER 03 · 4 LESSONS

03 · Functions

Learn the current compiler's typed function declaration syntax: funcra. Function parameters and return types are explicit. A pure funcra cannot perform effects such as output.

YOUR CHAPTER LEARNING PATH · सीखने का क्रम

Read. Check. Build.

Three linked steps using real Scarp source and verified output.

  1. Read the lessons · पाठ पढ़ें

    Work through all 4 verified examples. Save optional local lesson progress as you learn; this does not certify code execution.

    Start with Typed Functions ↗

    Lesson tracking is optional and only available when browser storage works.

  2. Check understanding · समझ जाँचें

    Try 3 bilingual questions linked directly to their original source and expected output. No quiz score is stored.

    Review all three questions here · यहाँ अभ्यास करें ↓
  3. Write Scarp · कोड लिखें

    Edit the real starter locally, compare output with the compiler-verified goal, and use the hint or tested solution when needed.

    Open Repair a typed function lab ↗

Lesson completion is voluntary local tracking. Passing a quiz or lab is not automatically recorded or claimed by this website. The Scarp compiler runs locally, not in your browser.

Lessons in this chapter

Practice this chapter · इस अध्याय का अभ्यास करें 3 bilingual, compiler-evidenced questions

Answer all three questions using the checked-in lessons. Feedback runs only in your browser; there is no stored score, automatic lesson completion or Scarp execution. Answers remain readable without JavaScript.

Question 1 of 3 · Typed Functions · View source and recorded output ↗

SOURCE-BACKED SELF-CHECK · स्रोत-आधारित अभ्यास

Quick checkpoint / त्वरित अभ्यास

What is the first number printed by add(10, square(5))?add(10, square(5)) से प्रिंट होने वाली पहली संख्या क्या है?

Reveal the source-backed answer / सही उत्तर देखें

35 — square(5) returns 25; add(10, 25) returns 35. The source calls these functions before their declarations.35 — square(5) का परिणाम 25 है। फिर add(10, 25) का परिणाम 35 होता है।

This question checks understanding of a recorded compiler output. It does not run Scarp in the browser. यह प्रश्न सत्यापित आउटपुट पर आधारित है; ब्राउज़र में Scarp नहीं चलता।

Question 2 of 3 · Recursion · View source and recorded output ↗

SOURCE-BACKED SELF-CHECK · स्रोत-आधारित अभ्यास

Quick checkpoint / त्वरित अभ्यास

What does fib(10) print in this recursive example?इस recursive उदाहरण में fib(10) क्या प्रिंट करता है?

Reveal the source-backed answer / सही उत्तर देखें

55 — The function returns n when n is at most 1 and otherwise adds fib(n - 1) and fib(n - 2); fib(10) is 55.55 — n का मान 1 या उससे कम होने पर फ़ंक्शन n लौटाता है; अन्यथा पिछले दो Fibonacci मान जोड़ता है। fib(10) = 55 है।

This question checks understanding of a recorded compiler output. It does not run Scarp in the browser. यह प्रश्न सत्यापित आउटपुट पर आधारित है; ब्राउज़र में Scarp नहीं चलता।

Question 3 of 3 · Function Contracts · View source and recorded output ↗

SOURCE-BACKED SELF-CHECK · स्रोत-आधारित अभ्यास

Quick checkpoint / त्वरित अभ्यास

What does clipped(x: 15) return with the default maximum of 10?डिफ़ॉल्ट अधिकतम 10 होने पर clipped(x: 15) क्या लौटाता है?

Reveal the source-backed answer / सही उत्तर देखें

10 — clipped uses defaults lo = 0 and hi = 10. Because x is greater than hi, it returns 10.10 — clipped में डिफ़ॉल्ट lo = 0 और hi = 10 हैं। x, hi से अधिक है, इसलिए फ़ंक्शन 10 लौटाता है।

This question checks understanding of a recorded compiler output. It does not run Scarp in the browser. यह प्रश्न सत्यापित आउटपुट पर आधारित है; ब्राउज़र में Scarp नहीं चलता।

All examples are validated with Scarp v0.0.6-alpha.3. Each lesson has its own code and expected-output page.