[Haskell-cafe] Fixed points
alex.solla at gmail.com
Fri Jun 10 21:05:09 CEST 2011
On Thu, Jun 9, 2011 at 6:04 PM, Felipe Almeida Lessa <felipe.lessa at gmail.com
> Something like this?
> equivalenceClosure = fix $ \f e ->
> let e' = reflexivity . symmetry . transitivity $ e
> in if e' == e then e else f e'
I managed something even "clearer". I still have very little intuition
about what's going on, but I had an aha moment -- which I promptly forgot
:0( -- and at least there's a mechanical translation from the iterate
version to the fix one.
equivalenceClosure :: (Ord a) => Relation a -> Relation a
equivalenceClosure = fix (\f -> reflexivity . symmetry . transitivity)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe