Stable marriage problem: Difference between revisions
Content added Content deleted
Line 2,756: | Line 2,756: | ||
<lang Haskell>stableMatching :: Eq a => State a -> [Couple a] |
<lang Haskell>stableMatching :: Eq a => State a -> [Couple a] |
||
stableMatching = getPairs . |
stableMatching = getPairs . until (null._freeGuys) step |
||
where |
where |
||
iterateUntil p f = head . dropWhile (not . p) . iterate f |
|||
getPairs s = map (_2 %~ head) $ s^.guys |
getPairs s = map (_2 %~ head) $ s^.guys |
||