Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import qualified Data.Set.Monad as S
- fix f init = until (\x -> x == f x) f init
- close rstar = fix (\s -> s `S.union` (rstar s))
- rstar g s = do { x <- s; (x, y) <- g; pure y }
- reachable g = close (rstar g)
- -- g1 = S.fromList [(1, 2), (2, 3), (3, 1), (4, 1)]
- -- reachable g1 (S.singleton 1) == S.fromList [1, 2, 3]
Add Comment
Please, Sign In to add comment