[pure-lang-svn] SF.net SVN: pure-lang:[702] pure/trunk/examples/hello.pure
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-09-04 16:13:42
|
Revision: 702 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=702&view=rev Author: agraef Date: 2008-09-04 16:13:51 +0000 (Thu, 04 Sep 2008) Log Message: ----------- Fixed point combinator is now defined in the prelude. Modified Paths: -------------- pure/trunk/examples/hello.pure Modified: pure/trunk/examples/hello.pure =================================================================== --- pure/trunk/examples/hello.pure 2008-09-04 16:12:04 UTC (rev 701) +++ pure/trunk/examples/hello.pure 2008-09-04 16:13:51 UTC (rev 702) @@ -84,9 +84,9 @@ // Using fixed points. This technique allows you to define a recursive // function without referring to the name of the function in its body. See // http://en.wikipedia.org/wiki/Fixed_point_combinator for an explanation. +// The (normal order) fixed point combinator 'fix' is defined in the prelude. -fact6 = Z (\f n -> if n<=0 then 1 else n*f (n-1)); -Z = \f -> (\x -> f (\y -> x x y)) (\x -> f (\y -> x x y)); +fact6 = fix (\f n -> if n<=0 then 1 else n*f (n-1)); // These should all evaluate to the same list of the first 10 factorials. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |