-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
280 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
|
||
use std::{io::println, u32}; | ||
|
||
fn main(&io) { | ||
refs(&io); | ||
io.println(""); | ||
fns(&io); | ||
io.println(""); | ||
rev(&io); | ||
} | ||
|
||
fn refs(&io){ | ||
let x = 0; | ||
inc((move x, move ~x)); | ||
io.println("x = " ++ u32::to_string(x)); | ||
inc((move x, move ~x)); | ||
io.println("x = " ++ u32::to_string(x)); | ||
inc((move x, move ~x)); | ||
io.println("x = " ++ u32::to_string(x)); | ||
} | ||
|
||
mod refs { | ||
fn inc((init, ~fin)) { | ||
fin = init + 1; | ||
} | ||
} | ||
|
||
fn fns(&io) { | ||
let f = { let n; (move ~n, n * n) }; | ||
io.println("f(1) = " ++ u32::to_string(call(f, 1))); | ||
io.println("f(2) = " ++ u32::to_string(call(f, 2))); | ||
io.println("f(3) = " ++ u32::to_string(call(f, 3))); | ||
} | ||
|
||
mod fns { | ||
fn call(f, a) { | ||
let (~i, o) = f; | ||
i = a; | ||
o | ||
} | ||
} | ||
|
||
fn rev(&io) { | ||
let s; | ||
~s = "0"; | ||
io.println("s = " ++ ~s); | ||
io.println("s = " ++ ~s); | ||
~s = "1"; | ||
io.println("s = " ++ get(&s)); | ||
io.println("s = " ++ get(&s)); | ||
set(&s, "2"); | ||
} | ||
|
||
mod rev { | ||
fn get(&x) { ~x } | ||
fn set(&x, value) { ~x = value } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
|
||
::main { ::inverse::main } | ||
|
||
::inverse::main { | ||
fn(ref(n0 n7) _) | ||
::inverse::refs = fn(ref(n0 n1) _) | ||
::std::io::println = fn(ref(n1 n3) fn(tup(0 fn(n2 n2)) _)) | ||
::inverse::fns = fn(ref(n3 n4) _) | ||
::std::io::println = fn(ref(n4 n6) fn(tup(0 fn(n5 n5)) _)) | ||
::inverse::rev = fn(ref(n6 n7) _) | ||
} | ||
|
||
::inverse::refs { | ||
fn(ref(n0 n9) _) | ||
::inverse::refs::inc = fn(tup(0 dup5(n14 n15)) _) | ||
::std::io::println = fn(ref(n0 n4) fn(n3 _)) | ||
::std::u32::to_string = fn(n14 n2) | ||
::std::str::concat = fn(tup(4 fn(n1 tup(120 tup(32 tup(61 tup(32 n1)))))) fn(n2 n3)) | ||
::inverse::refs::inc = fn(tup(n15 dup5(n16 n17)) _) | ||
::std::io::println = fn(ref(n4 n8) fn(n7 _)) | ||
::std::u32::to_string = fn(n16 n6) | ||
::std::str::concat = fn(tup(4 fn(n5 tup(120 tup(32 tup(61 tup(32 n5)))))) fn(n6 n7)) | ||
::inverse::refs::inc = fn(tup(n17 n11) _) | ||
::std::io::println = fn(ref(n8 n9) fn(n13 _)) | ||
::std::u32::to_string = fn(n11 n12) | ||
::std::str::concat = fn(tup(4 fn(n10 tup(120 tup(32 tup(61 tup(32 n10)))))) fn(n12 n13)) | ||
} | ||
|
||
::inverse::refs::inc { fn(tup(@add(1 n0) n0) _) } | ||
|
||
::inverse::fns { | ||
fn(ref(n1 n12) _) | ||
::std::io::println = fn(ref(n1 n6) fn(n5 _)) | ||
::inverse::fns::call = fn(n18 fn(1 n3)) | ||
::std::u32::to_string = fn(n3 n4) | ||
::std::str::concat = fn(tup(7 fn(n2 tup(102 tup(40 tup(49 tup(41 tup(32 tup(61 tup(32 n2))))))))) fn(n4 n5)) | ||
::std::io::println = fn(ref(n6 n11) fn(n10 _)) | ||
::inverse::fns::call = fn(n19 fn(2 n8)) | ||
::std::u32::to_string = fn(n8 n9) | ||
::std::str::concat = fn(tup(7 fn(n7 tup(102 tup(40 tup(50 tup(41 tup(32 tup(61 tup(32 n7))))))))) fn(n9 n10)) | ||
::std::io::println = fn(ref(n11 n12) fn(n16 _)) | ||
::inverse::fns::call = fn(n20 fn(3 n14)) | ||
::std::u32::to_string = fn(n14 n15) | ||
::std::str::concat = fn(tup(7 fn(n13 tup(102 tup(40 tup(51 tup(41 tup(32 tup(61 tup(32 n13))))))))) fn(n15 n16)) | ||
tup(dup13(@mul(n17 n0) n17) n0) = dup14(n18 dup14(n19 n20)) | ||
} | ||
|
||
::inverse::fns::call { fn(tup(n0 n1) fn(n0 n1)) } | ||
|
||
::inverse::rev { | ||
fn(ref(n1 n15) _) | ||
_ = tup(1 fn(n0 tup(48 n0))) | ||
::std::io::println = fn(ref(n1 n5) fn(n4 _)) | ||
::std::str::concat = fn(tup(4 fn(n2 tup(115 tup(32 tup(61 tup(32 n2)))))) fn(n3 n4)) | ||
::std::io::println = fn(ref(n5 n10) fn(n8 _)) | ||
::std::str::concat = fn(tup(4 fn(n6 tup(115 tup(32 tup(61 tup(32 n6)))))) fn(n7 n8)) | ||
dup(dup(_ n3) n7) = tup(1 fn(n9 tup(49 n9))) | ||
::std::io::println = fn(ref(n10 n14) fn(n13 _)) | ||
::inverse::rev::get = fn(ref(_ n17) n12) | ||
::std::str::concat = fn(tup(4 fn(n11 tup(115 tup(32 tup(61 tup(32 n11)))))) fn(n12 n13)) | ||
::std::io::println = fn(ref(n14 n15) fn(n19 _)) | ||
::inverse::rev::get = fn(ref(n17 n20) n18) | ||
::std::str::concat = fn(tup(4 fn(n16 tup(115 tup(32 tup(61 tup(32 n16)))))) fn(n18 n19)) | ||
::inverse::rev::set = fn(ref(n20 _) fn(tup(1 fn(n21 tup(50 n21))) _)) | ||
} | ||
|
||
::inverse::rev::get { fn(ref(n0 dup(n0 n1)) n1) } | ||
|
||
::inverse::rev::set { fn(ref(n0 _) fn(n0 _)) } | ||
|
||
::std::io::println { | ||
fn(ref(n0 n3) fn(n1 _)) | ||
::std::io::print = fn(ref(n0 n2) fn(n1 _)) | ||
::std::io::print_char = fn(ref(n2 n3) fn(10 _)) | ||
} | ||
|
||
::std::io::print { | ||
fn(ref(n0 n1) fn(tup(n2 fn(_ n3)) _)) | ||
::std::io::print::1 = x(n0 x(n1 x(n2 n3))) | ||
} | ||
|
||
::std::io::print::1 { x(n0 x(n1 x(dup42(?(::std::io::print::3 ::std::io::print::2 x(n0 x(n1 x(n3 n2)))) n3) n2))) } | ||
|
||
::std::io::print::2 { | ||
x(n1 x(n3 x(@sub(1 n4) tup(n0 n5)))) | ||
::std::io::print_char = fn(ref(n1 n2) fn(n0 _)) | ||
::std::io::print::1 = x(n2 x(n3 x(n4 n5))) | ||
} | ||
|
||
::std::io::print::3 { x(n0 x(n0 _)) } | ||
|
||
::std::io::print_char { fn(ref(@io_print_char(char io) io) fn(char _)) } | ||
|
||
::std::str::concat { fn(tup(@add(n0 n1) fn(n3 n4)) fn(tup(n0 fn(n2 n3)) tup(n1 fn(n2 n4)))) } | ||
|
||
::std::u32::to_string { fn(dup176(?(::std::u32::to_string::5 ::std::u32::to_string::1 x(n1 n0)) n1) n0) } | ||
|
||
::std::u32::to_string::1 { | ||
x(n1 n2) | ||
::std::u32::to_string::2 = x(n1 x(tup(0 fn(n0 n0)) n2)) | ||
} | ||
|
||
::std::u32::to_string::2 { x(dup176(?(::std::u32::to_string::4 ::std::u32::to_string::3 x(n2 n0)) n2) n0) } | ||
|
||
::std::u32::to_string::3 { | ||
x(dup176(@rem(10 n1) @div(10 n5)) x(tup(@add(1 n0) fn(n3 n4)) n6)) | ||
48 = @add(n1 n2) | ||
::std::u32::to_string::2 = x(n5 x(tup(n0 fn(n3 tup(n2 n4))) n6)) | ||
} | ||
|
||
::std::u32::to_string::4 { x(_ x(n0 n0)) } | ||
|
||
::std::u32::to_string::5 { x(_ tup(1 fn(n0 tup(48 n0)))) } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
x = 1 | ||
x = 2 | ||
x = 3 | ||
|
||
f(1) = 1 | ||
f(2) = 4 | ||
f(3) = 9 | ||
|
||
s = 1 | ||
s = 1 | ||
s = 2 | ||
s = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
Interactions | ||
Total 1_965 | ||
Annihilate 1_027 | ||
Commute 18 | ||
Copy 131 | ||
Erase 233 | ||
Expand 297 | ||
Call 170 | ||
Branch 89 | ||
|
||
Memory | ||
Heap 1_840 B | ||
Allocated 40_000 B | ||
Freed 40_000 B |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.