PUBLISHED SCARP v0.0.6-alpha.6 · SEPARATE COMPILER PIN
Read input and build an immutable tuple
Practice real read_line(), Unicode text trimming,
integer parsing, tuple returns and indexing. The source and expected output
below are the checked-in programs verified by the published alpha.6 compiler.
This lesson needs v0.0.6-alpha.6, built from its own immutable compiler commit. The 58 numbered course lessons use independently pinned alpha.17. Do not assume that commands and flags introduced later work with alpha.6.
Verify source
scarp verify tutorials/input-and-tuples/main.srpRun with exact input
scarp exec tutorials/input-and-tuples/main.srp < tutorials/input-and-tuples/main.stdinCompare output
tutorials/input-and-tuples/main.stdoutmain.srp
// Supply both lines through redirected UTF-8 stdin.
print("Profile");
bind name = text_trim(read_line());
bind points = text_to_integer(text_trim(read_line()));
pure funcra profile(label: string, score: integer) -> tuple<string, integer> {
return (label, score);
}
bind result = profile(name, points);
print(result);
print(text_concat("अंक: ", integer_to_text(result[1])));
stdout
Profile
("संस्कार 🌍", 42)
अंक: 42
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.
main.stdin
संस्कार 🌍
42
Displayed UTF-8 input is for reading only. Backslashes and control
bytes are shown visibly; the linked .stdin fixture is the source of exact
input bytes. Static scarp verify does not read input. The website
does not execute Scarp.
ENGLISH + हिन्दी
Understand the program
Line input is not static verification
verify checks code without reading stdin.
The interpreter receives two UTF-8 lines from the checked-in .stdin
file: a padded name and a numeric score. text_trim removes
surrounding whitespace; text_to_integer explicitly parses the
score. The pure profile function returns a
tuple<string, integer> with zero-based index access.
EOF and output atomicity
Input must include both lines. Early EOF produces E0055
and prevents buffered Profile output from being emitted.
The site displays recorded output instead of executing the program.
Original Scarp alpha.6 has no --interactive or --input-file flags; use stdin redirection in Git Bash or Command Prompt.
Practice: Copy the input file elsewhere, remove its second line and execute using that local copy. Observe the missing-input diagnostic, then restore both lines.
दो पंक्तियों से tuple बनाएँ
verify इनपुट लिए बिना static जाँच करता है।
read_line() पहले नाम और फिर अंक की लाइन पढ़ता है।
text_trim अतिरिक्त खाली जगह हटाता है और
text_to_integer अंक को integer में बदलता है।
profile function एक immutable tuple लौटाता है।
result[1] उसका दूसरा सदस्य है।
इनपुट खत्म होने पर
दूसरी लाइन न मिले तो E0055 त्रुटि आती है और
पहले लिखा Profile आउटपुट भी नहीं निकलता।
यह वेबसाइट कोड नहीं चलाती; केवल सत्यापित परिणाम दिखाती है।
अभ्यास: इनपुट फ़ाइल की अलग कॉपी में दूसरी लाइन हटाकर चलाएँ। फिर मूल दोनों लाइनें वापस रखें।
Both source and fixture are read directly from
Git-tracked files. A dedicated CI job builds exact compiler commit
cdf6a3924ec2a36c7beca5a9aec4f01a0bce515e and checks the real runtime, bytes and EOF behavior.
This browser never runs Scarp.
← Return to the course catalog
Independent release source:
v0.0.6-alpha.6 ·
cdf6a3924ec2a36c7beca5a9aec4f01a0bce515e. No simulated interpreter output.