diff options
author | c+1 | 2023-05-14 09:41:14 -0400 |
---|---|---|
committer | c+1 | 2023-05-14 09:41:14 -0400 |
commit | d03956f54d15f4904cfa10be96bbdf11d49a68f0 (patch) | |
tree | 6268879d3b513f49e693e3bb0d771bc00bff9faf /examples | |
parent | aceffe9d3eed82e025202e8d5661e5bdbb2fd358 (diff) |
halk
Diffstat (limited to 'examples')
-rw-r--r-- | examples/functional.halk | 19 |
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)))))))) |