CHAPTER 06 · 11 LESSONS

06 · Foundations for AI-oriented programs

Scarp has early numerical primitives useful for AI-related calculations. These exercises do not claim full AI frameworks, autodiff, GPU acceleration, model training systems or agent tooling.

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

Read. Check. Build.

Three linked steps using real Scarp source and verified output.

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

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

    Start with Matrix Inference ↗

    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 Choose a class as a one-hot vector 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 · Matrix Inference · View source and recorded output ↗

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

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

What output does matvec(weights, features) produce?matvec(weights, features) का आउटपुट क्या है?

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

[4.0, 1.0] — With rows [1.0, 2.0] and [-1.0, 3.0], multiplying by [2.0, 1.0] gives 4.0 and 1.0.[4.0, 1.0] — मैट्रिक्स की पंक्तियाँ [1.0, 2.0] और [-1.0, 3.0] हैं। इन्हें [2.0, 1.0] से गुणा करने पर 4.0 और 1.0 मिलते हैं।

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

Question 2 of 3 · Classification Gradient · View source and recorded output ↗

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

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

What gradient does lossgrad([0.0, 0.0], 1) print?lossgrad([0.0, 0.0], 1) कौन-सा gradient प्रिंट करता है?

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

[0.5, -0.5] — Equal logits imply probabilities of 0.5 for both classes. The loss gradient subtracts the one-hot target for class 1, producing [0.5, -0.5].[0.5, -0.5] — समान logits के लिए दोनों वर्गों की संभावना 0.5 होती है। class 1 के one-hot target को घटाने पर gradient [0.5, -0.5] मिलता है।

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

Question 3 of 3 · Classification Loss · View source and recorded output ↗

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

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

Which index does argmax([1.0, 4.0, 2.0]) print?argmax([1.0, 4.0, 2.0]) कौन-सा index प्रिंट करता है?

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

1 — The maximum value is 4.0, which is at zero-based index 1. The fixture prints 1.1 — सबसे बड़ा मान 4.0 है, जो शून्य-आधारित index 1 पर है। इसलिए आउटपुट 1 है.

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.