-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from billhails/poke-the-bear
Poke the bear
- Loading branch information
Showing
44 changed files
with
210 additions
and
14,126 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 |
---|---|---|
|
@@ -6,6 +6,7 @@ out_scm/ | |
tmp_scm/ | ||
cekf | ||
tags | ||
.generated | ||
.*.swp | ||
.$*.drawio.* | ||
callgrind.out.* | ||
|
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 was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
let | ||
a = 10; | ||
a = a + 2; | ||
in print(a) |
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,9 @@ | ||
let | ||
fn bad() { | ||
let | ||
typedef doh { re | mi } | ||
in | ||
re | ||
} | ||
in | ||
print(bad()) |
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,30 @@ | ||
// naive un-optimised quicksort implementation to | ||
// demonstrate the principle, see qqsort.fn for | ||
// an optimised version. | ||
let | ||
fn f1(a) { a + 1 } | ||
fn f2(a) { a - 1 } | ||
|
||
fn qsort { | ||
([]) { [] } | ||
(pivot @ rest) { | ||
let | ||
lesser = filter(fn (a, b) { a >= b }(pivot), rest); | ||
greater = filter(fn (a, b) { a < b }(pivot), rest); | ||
in | ||
qsort(lesser) @@ [pivot] @@ qsort(greater) | ||
} | ||
} | ||
|
||
fn filter { | ||
(f, []) { [] } | ||
(f, h @ t) { | ||
if (f(h)) { | ||
h @ filter(f, t) | ||
} else { | ||
filter(f, t) | ||
} | ||
} | ||
} | ||
in | ||
print(qsort([f1, f2])) |
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,32 @@ | ||
let | ||
fn require(condition) { | ||
condition or back | ||
} | ||
|
||
fn square(x) { x * x } | ||
|
||
fn integers_from(n) { | ||
n then integers_from(n + 1) | ||
} | ||
|
||
fn integers_between(lower, upper) { | ||
require(lower <= upper); | ||
lower then integers_between(lower + 1, upper) | ||
} | ||
|
||
fn pythagorean_triples() { | ||
let | ||
z = integers_from(1); | ||
x = integers_between(1, z); | ||
y = integers_between(x, z); | ||
in | ||
require(square(x) + square(y) == square(z)); | ||
[x, y, z] | ||
} | ||
in { | ||
let triple = pythagorean_triples(); | ||
in | ||
print(triple); | ||
puts("\n"); | ||
require(<triple > 20) // until | ||
} |
Oops, something went wrong.