forked from advancedresearch/path_semantics
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
4 changed files
with
78 additions
and
0 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,3 @@ | ||
/target/ | ||
Cargo.lock | ||
|
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,10 @@ | ||
[package] | ||
name = "scomb" | ||
version = "0.1.0" | ||
authors = ["Sven Nilsen <bvssvni@gmail.com>"] | ||
|
||
[[bin]] | ||
name = "scomb" | ||
|
||
[dependencies] | ||
dyon = "0.24.5" |
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,58 @@ | ||
fn main() { | ||
/* | ||
// λf.((λx.x x)(λx.f (x x))) | ||
y := \(f) = { | ||
x := \(x) = \x(x) | ||
\(x) = { | ||
f := grab f | ||
\f(\x(x)) | ||
} | ||
} | ||
a := \y(\(f) = \(ind) = { | ||
println(ind) | ||
if ind > 0 { | ||
f := grab f | ||
y := grab '2 y | ||
println(f) | ||
println(\f(y)) | ||
} | ||
3 | ||
}) | ||
b := \a(y) | ||
// println(b) | ||
println(\b(1)) | ||
*/ | ||
|
||
h := \(x, ind) = { | ||
// println(ind) | ||
if ind == 1 { | ||
1 | ||
} else { | ||
collatz := if (ind % 2) == 0 {ind / 2} else {3 * ind + 1} | ||
ind + \x(collatz) | ||
} | ||
} | ||
|
||
h := \(self, n) = { | ||
if n == 0 {0} else if n == 1 {1} else {\self(n-1) + \self(n-2)} | ||
} | ||
|
||
sc := \(sc, f) = \(n) = { | ||
sc := grab sc | ||
f := grab f | ||
\f(\sc(sc, f), n) | ||
} | ||
|
||
// First you create the combinator. | ||
// println(a) | ||
|
||
// Then you pass the combinator to itself. | ||
b := \sc(sc, h) | ||
// println(b) | ||
|
||
// Then you pass the value you want to compute. | ||
for i [1, 10) { | ||
println(\b(i)) | ||
} | ||
println(\b(20)) | ||
} |
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,7 @@ | ||
extern crate dyon; | ||
|
||
use dyon::{error, run}; | ||
|
||
fn main() { | ||
error(run("src/main.dyon")); | ||
} |