From caf7593edd2b94547444a831788bb377350b976b Mon Sep 17 00:00:00 2001 From: c+1 Date: Thu, 18 May 2023 18:24:56 -0400 Subject: updated functional.halk with new syntax --- examples/functional.halk | 28 +++++++++------------------- 1 file 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)))))))) -- cgit v1.2.3