2024-05-09 22:11:20 +03:00
|
|
|
#flavor core
|
2024-01-10 14:53:06 +03:00
|
|
|
// This program is an example that shows how scopeless lambdas can be used.
|
|
|
|
|
2024-01-09 22:46:49 +03:00
|
|
|
Seq a b = a
|
2024-01-08 23:44:03 +03:00
|
|
|
|
2024-01-09 22:46:49 +03:00
|
|
|
// Create a program capable of using `callcc`
|
|
|
|
CC.lang = λprogram
|
|
|
|
let callcc = λcallback (λ$garbage($hole) (callback λ$hole(0)));
|
|
|
|
let result = (program callcc);
|
|
|
|
let garbage = $garbage; // Discard `$garbage`, which is the value returned by `callback`
|
|
|
|
(Seq result garbage)
|
2024-01-08 23:44:03 +03:00
|
|
|
|
2024-04-26 23:35:42 +03:00
|
|
|
main = (CC.lang λcallcc
|
2024-01-09 22:46:49 +03:00
|
|
|
// This code calls `callcc`, then calls `k` to fill the hole with `42`. This means that the call to callcc returns `42`, and the program returns `52`
|
|
|
|
(+ 10 (callcc λk(+ (k 42) 1729)))
|
|
|
|
)
|