Typed callable values
ASPL 0.7.0 · Current release
Pass a callable through a list, result and record, then print 42 and return 0.
On this page
Purpose and preparation
Browser and native, ASPL 0.7.0. Uses typed functions, lists, records and results. No input lines, data assets or source modules are required. It passes a callable through each container, compares its identity, prints 42 followed by LF and returns 0.
Arabic source
Open a new browser draft, then select Run explicitly. Opening checks without executing.
Execution: Browser and native · ASPL 0.7.0
- Uses functions, lists, records and results. No data files are required.
Input: No input lines are required.
دالة زيادة(قيمة: ص64) -> ص64 { أرجع قيمة + 4. }
دالة اختر() -> دالة(ص64) -> ص64 { أرجع زيادة. }
سجل حامل { استدعاء: دالة(ص64) -> ص64 }
دالة طبق(عمل: دالة(ص64) -> ص64, قيمة: ص64) -> ص64 { أرجع عمل(قيمة). }
دالة ابدأ_الرئيسية() -> ص64 {
دع محفوظ: قائمة<دالة(ص64) -> ص64> = [اختر()].
دع مغلف: نتيجة<دالة(ص64) -> ص64> = نجاح(محفوظ[0]).
دع عنصر = حامل { استدعاء: مغلف::قيمة }.
إذا عنصر::استدعاء لا يطابق زيادة { أرجع 1. }
اطبع(نسق_ص64(طبق(عنصر::استدعاء, 38)) + "\س").
أرجع 0.
}
Expected outcomes
{
"browser": {
"check": "success",
"class": "success",
"output": "42\n",
"processStatus": 0
},
"native": {
"check": 0,
"status": 0,
"output": "42\n"
}
}English source
Open a new browser draft, then select Run explicitly. Opening checks without executing.
Execution: Browser and native · ASPL 0.7.0
- Uses functions, lists, records and results. No data files are required.
Input: No input lines are required.
fn increment(value: i64) -> i64 { return value + 4; }
fn choose() -> fn(i64) -> i64 { return increment; }
record Carrier { callback: fn(i64) -> i64 }
fn apply(action: fn(i64) -> i64, value: i64) -> i64 { return action(value); }
fn start_main() -> i64 {
let saved: list<fn(i64) -> i64> = [choose()];
let wrapped: result<fn(i64) -> i64> = success(saved[0]);
let carrier = Carrier { callback: wrapped::value };
if carrier::callback not matches increment { return 1; }
print(format_i64(apply(carrier::callback, 38)) + "\n");
return 0;
}
Expected outcomes
{
"browser": {
"check": "success",
"class": "success",
"output": "42\n",
"processStatus": 0
},
"native": {
"check": 0,
"status": 0,
"output": "42\n"
}
}Check the result
Source cards show exact catalog outcomes. Downloads retain original bytes, digests and supplied vocabulary.