aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-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))))))))