Mutate independent list copies
ASPL 0.7.0 · Current release
Complete supplied source, preparation, and checked ASPL 0.7.0 outcomes.
On this page
Purpose and preparation
Browser and native, ASPL 0.7.0. Appends, replaces elements, and checks nested and exact-width copies remain independent. Prints 32 with status 0.
See the current reference. No source module or external library is required.
Arabic source
This supplied complete source opens a new draft. Prepare the declared inputs/files in that draft, then select Run explicitly.
Execution: Browser and native · ASPL 0.7.0
- No prior knowledge is required to open and check it.
Input: No input lines are required.
دالة ابدأ_الرئيسية() -> ص64 {
متغير قيم: قائمة<ص64> = [1, 2].
أضف(قيم, 3).
إذا (طول(قيم) لا يطابق 3) { أرجع 1. }
متغير نسخة: قائمة<ص64> = قيم.
نسخة[0] = 9.
إذا (قيم[0] لا يطابق 1) { أرجع 2. }
إذا (نسخة[0] لا يطابق 9) { أرجع 3. }
أضف(قيم, قيم[0]).
إذا (طول(قيم) لا يطابق 4) { أرجع 4. }
إذا (قيم[3] لا يطابق 1) { أرجع 5. }
متغير متداخل: قائمة<قائمة<ص64>> = [[1], [2]].
دع نسخة_متداخلة: قائمة<قائمة<ص64>> = متداخل.
متداخل[0][0] = 7.
إذا (نسخة_متداخلة[0][0] لا يطابق 1) { أرجع 6. }
إذا (متداخل[0][0] لا يطابق 7) { أرجع 7. }
متغير موسع: قائمة<ص64> = [].
متغير ك = 0.
طالما (ك < 32) { أضف(موسع, ك * 2). ك = ك + 1. }
إذا (طول(موسع) لا يطابق 32) { أرجع 8. }
إذا (موسع[31] لا يطابق 62) { أرجع 9. }
موسع[0] = موسع[31].
إذا (موسع[0] لا يطابق 62) { أرجع 10. }
متغير بايتات: قائمة<ط8> = [0, 255].
متغير نسخة_بايتات: قائمة<ط8> = بايتات.
نسخة_بايتات[0] = 255.
إذا (بايتات[0] لا يطابق 0 أو نسخة_بايتات[0] لا يطابق 255) { أرجع 11. }
متغير كسور: قائمة<ع64> = [0.5].
كسور[0] = 1.5.
إذا (كسور[0] لا يطابق 1.5) { أرجع 12. }
اطبع("32").
أرجع 0.
}
Expected outcomes
{
"browser": {
"check": "success",
"class": "success",
"output": "32",
"processStatus": 0
},
"native": {
"check": 0,
"status": 0,
"output": "32"
}
}English source
This supplied complete source opens a new draft. Prepare the declared inputs/files in that draft, then select Run explicitly.
Execution: Browser and native · ASPL 0.7.0
- No prior knowledge is required to open and check it.
Input: No input lines are required.
fn start_main() -> i64 {
var xs: list<i64> = [1, 2];
append(xs, 3);
if (length(xs) not match 3) { return 1; }
var copy: list<i64> = xs;
copy[0] = 9;
if (xs[0] not match 1) { return 2; }
if (copy[0] not match 9) { return 3; }
append(xs, xs[0]);
if (length(xs) not match 4) { return 4; }
if (xs[3] not match 1) { return 5; }
var nested: list<list<i64>> = [[1], [2]];
let nested_copy: list<list<i64>> = nested;
nested[0][0] = 7;
if (nested_copy[0][0] not match 1) { return 6; }
if (nested[0][0] not match 7) { return 7; }
var grown: list<i64> = [];
var k = 0;
while (k < 32) { append(grown, k * 2); k = k + 1; }
if (length(grown) not match 32) { return 8; }
if (grown[31] not match 62) { return 9; }
grown[0] = grown[31];
if (grown[0] not match 62) { return 10; }
var bytes: list<u8> = [0, 255];
var byte_copy: list<u8> = bytes;
byte_copy[0] = 255;
if (bytes[0] not match 0 or byte_copy[0] not match 255) { return 11; }
var fractions: list<f64> = [0.5];
fractions[0] = 1.5;
if (fractions[0] not match 1.5) { return 12; }
print("32");
return 0;
}
Expected outcomes
{
"browser": {
"check": "success",
"class": "success",
"output": "32",
"processStatus": 0
},
"native": {
"check": 0,
"status": 0,
"output": "32"
}
}Mixed source
This supplied complete source opens a new draft. Prepare the declared inputs/files in that draft, then select Run explicitly.
Execution: Browser and native · ASPL 0.7.0
- No prior knowledge is required to open and check it.
Input: No input lines are required.
fn start_main() -> i64 {
متغير xs: list<ص64> = [1, 2];
append(xs, 3);
إذا (طول(xs) not match 3) { أرجع 1. }
var نسخة: قائمة<i64> = xs;
نسخة[0] = 9;
if (xs[0] not match 1) { return 2; }
إذا (نسخة[0] not match 9) { أرجع 3. }
append(xs, xs[0]);
if (طول(xs) not match 4) { return 4; }
إذا (xs[3] not match 1) { أرجع 5. }
متغير nested: list<قائمة<ص64>> = [[1], [2]];
let nested_copy: قائمة<list<ص64>> = nested;
nested[0][0] = 7;
if (nested_copy[0][0] not match 1) { return 6; }
إذا (nested[0][0] not match 7) { أرجع 7. }
var grown: list<i64> = [];
متغير k = 0;
while (k < 32) { أضف(grown, k * 2); k = k + 1. }
if (length(grown) not match 32) { return 8; }
if (grown[31] not match 62) { return 9; }
grown[0] = grown[31];
إذا (grown[0] not match 62) { أرجع 10. }
var bytes: قائمة<u8> = [0, 255];
متغير byte_copy: list<ط8> = bytes.
byte_copy[0] = 255;
if (bytes[0] not match 0 or byte_copy[0] not match 255) { return 11. }
var fractions: قائمة<f64> = [0.5];
fractions[0] = 1.5;
إذا (fractions[0] not match 1.5) { أرجع 12. }
print("32");
return 0;
}
Expected outcomes
{
"browser": {
"check": "success",
"class": "success",
"output": "32",
"processStatus": 0
},
"native": {
"check": 0,
"status": 0,
"output": "32"
}
}Check the result
The source cards show the catalog's exact inputs and outcomes. Locale changes do not translate the supplied source. Download retains original source bytes.