SCARP v0.0.6-alpha.20

Tuple snapshot independence

Keep the old tuple while replacing a member in a mutable binding.

Compiler: published alpha.20 · b1a9347f93540fdf95b0ddecba4adc55a3b4bb98

Original Scarp by Example teaching program (MIT), executed by the pinned compiler.

Predict before running

Why is (1, 90) less than (2, 0), regardless of the second member?

tuple_snapshots.srp

// A tuple member update replaces the value held by a mutable binding.
var reading = (12, "pending");
bind original = reading;
reading[0] = 15;
reading[1] = "ready";
print(reading);
print(original);
print((1, 90) < (2, 0));
print((2, 4) < (2, 3));

tuple_snapshots.stdout

(15, "ready")
(12, "pending")
true
false

Run on your computer

scarp verify tutorials/alpha20-exact-values/tuple_snapshots.srp
scarp exec tutorials/alpha20-exact-values/tuple_snapshots.srp

The website does not execute code in your browser. Compare local output against the fixture.

हिन्दी में अभ्यास

(1, 90) और (2, 0) में दूसरे सदस्य से पहले पहला सदस्य क्यों देखा जाता है?