
Frank Atanassow wrote:
This is a situation where the explicit fixpoint datatype comes in handy:
data Fix f = In (f (Fix f))
...
BTW, this is not a beginner, or even intermediate, Haskell programmer's technique.
For those who are interested in what exactly is or isn't a beginner or intermediate Haskell programmer's technique, I humbly offer the following http://www.willamette.edu/~fruehr/haskell/evolution.html which includes examples of the afore-mentioned approach, along with many others, from accumulating parameters to comonads. Fair warning: tongue held firmly in cheek ... -- Fritz Ruehr fruehr@willamette.edu

On Mon, Aug 20, 2001 at 10:35:38AM -0700, Fritz K Ruehr wrote:
For those who are interested in what exactly is or isn't a beginner or intermediate Haskell programmer's technique, I humbly offer the following
http://www.willamette.edu/~fruehr/haskell/evolution.html
which includes examples of the afore-mentioned approach, along with many others, from accumulating parameters to comonads.
Another version: fac = foldr (*) 1 . unfoldr (\n -> guard (n > 0) >> return (n, n-1)) Also, the combinatory programmer would regard defining y by recursion as cheating, and would probably prefer one of these versions: newtype SelfApp a = SA (SelfApp a -> a) selfApply :: SelfApp a -> a selfApply (SA f) = f (SA f) yCurry :: (a -> a) -> a yCurry f = selfApply (SA (\x -> f (selfApply x))) yTuring :: (a -> a) -> a yTuring = selfApply (SA (\x f -> f (selfApply x f)))
participants (2)
-
Fritz K Ruehr
-
Ross Paterson