aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorc+12023-05-14 09:41:14 -0400
committerc+12023-05-14 09:41:14 -0400
commitd03956f54d15f4904cfa10be96bbdf11d49a68f0 (patch)
tree6268879d3b513f49e693e3bb0d771bc00bff9faf
parentaceffe9d3eed82e025202e8d5661e5bdbb2fd358 (diff)
halk
-rw-r--r--examples/functional.halk19
1 files changed, 16 insertions, 3 deletions
diff --git a/examples/functional.halk b/examples/functional.halk
index ba61210..d050662 100644
--- a/examples/functional.halk
+++ b/examples/functional.halk
@@ -3,8 +3,21 @@ use of '=>' instead of '->', to denote a function
whom's arguments are immutable.]
let.Y => {
- λ.f => {
- λ.x => f.x.x;
- }.λ.x => f.x.x;
+ λ.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);
+ }
+ }}
+}
+
+(define Fact
+ (Y (λ (fact) (λ (n) (if (zero? n) 1 (* n (fact (- n 1))))))))