aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/functional.halk28
1 files changed, 9 insertions, 19 deletions
diff --git a/examples/functional.halk b/examples/functional.halk
index d050662..e22fab5 100644
--- a/examples/functional.halk
+++ b/examples/functional.halk
@@ -1,23 +1,13 @@
-[the Y combinator, implemented in HALK. Note the
-use of '=>' instead of '->', to denote a function
-whom's arguments are immutable.]
+` the Y-Combinator in HALK `
+` an empty : when not proceeded by a type is shorthand for any: `
-let.Y => {
- λ.b => {
- (λ.f => { b.λ.x => { (f.f).x } }).
- (λ.f => { b.λ.x => { (f.f).x } });
- }
-}
-let.Fact => {
- Y.λ.fact => {λ.n => {
- if.(zero?.n), {
- 1;
- }, {
- *.n, (fact. -.n, 1);
+:Y = {
+ :λ.:f = {
+ :λ.:x = {
+ f.x.x
+ }. :λ.:x = {
+ f.x.x
}
- }}
+ }
}
-
-(define Fact
- (Y (λ (fact) (λ (n) (if (zero? n) 1 (* n (fact (- n 1))))))))