On Mon, Sep 05, 2005 at 12:35:36PM +0900, Dan Kogai wrote:
> And I found that these can be made much, much simpler and more  
> intuitive with Perl 6, even more so than scheme!
> 
>   our $ZERO = sub($f){ sub($x){ $x }};
>   our $SUCC = sub($n){ sub($f){ sub($x){ $f.($n.($f)($x)) }}};
>   our $ADD  = sub($m){ sub($n){ sub($f){ sub($x){ $m.($f)($n.($f) 
> ($x)) }}}};
>   our $MULT = sub($m){ sub($n){ sub($f){ $m.($n.($f)) }}};
>   our $POW  = sub($m){ sub($n){ $n.($m) }};

Nice!  Also the pointy notation may or may not be clearer:

    -> $f { -> $x { $x } }

Also, you can use the & sigil:

    our &SUCC := sub(&n){ sub(&f){ sub(&x){ f(n(&f)(&x)) }}};

which may or may not be clearer... probably not, come to think about it.

> P.S.  I am surprised to find Pugs does not include this kind of  
> sample scripts.

I'm surprised to find dan-san is not a Pugs committer.  I've remedied
this situation by sending you an invitation.  The commit URL is the
same as the anonymous checkout svn URL.

Please commit them into the suitable examples/ subdirectory, probably
"algorithms".  Also please add yourself to AUTHORS.  Welcome aboard!

Thanks,
/Autrijus/

Attachment: pgpERLqoLpAGo.pgp
Description: PGP signature

Reply via email to