diff options
author | c+1 | 2023-05-18 18:24:56 -0400 |
---|---|---|
committer | c+1 | 2023-05-18 18:24:56 -0400 |
commit | caf7593edd2b94547444a831788bb377350b976b (patch) | |
tree | 0d558792e06d07a2d28ae8d2e8fba206025650fa /examples | |
parent | 5ab53b80334b6a9e849c46bd2998b163b0b7f72c (diff) |
updated functional.halk with new syntax
Diffstat (limited to 'examples')
-rw-r--r-- | examples/functional.halk | 28 |
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)))))))) |