LESSON 45 OF 52 · CHAPTER 06

Score Selection

Deterministic argmax/argmin and extremum values

ORIGINAL SOURCE

04-score-selection.srp

// A stable, first-match score winner.
bind scores = [1.0, 3.0, 3.0];
print(argmax(scores), maxval(scores));
print(argmin(scores), minval(scores));
EXPECTED OUTPUT

stdout

Verified
1 3.0
0 1.0

UNDERSTAND THE CODE

Explanation & practice

What this example teaches

Deterministic argmax/argmin and extremum values

Expected behavior

1 3.0, then 0 1.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.

स्कोर चुनना और टाई

argmax अधिकतम स्कोर का इंडेक्स और maxval उसका मान बताता है। argmin एवं minval न्यूनतम के लिए हैं। दो बार अधिकतम 3.0 होने पर वर्तमान उदाहरण पहले इंडेक्स को चुनता है।

आउटपुट: पहले 1 3.0, फिर 0 1.0।

अभ्यास: यदि अधिकतम मान एक से अधिक स्थानों पर हो तो इस उदाहरण में कौन-सा चुना जाता है?

Explanations are sourced from the project's English chapter guide and हिन्दी अध्याय. The Scarp program and output are unchanged.

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/06-ai-foundations/04-score-selection.srp scarp exec examples/06-ai-foundations/04-score-selection.srp

The website does not run code. Read the CLI guide ↗

Pinned compiler: Scarp v0.0.6-alpha.3 · ceff07d9014f. No simulated output.