Topological sort: Difference between revisions

Content added Content deleted
m (added to a category.)
m (→‎{{header|Haskell}}: Used Data.Bifunctor in place of Control.Arrow)
Line 2,442: Line 2,442:
=={{header|Haskell}}==
=={{header|Haskell}}==
<lang haskell>import Data.List ((\\), elemIndex, intersect, nub)
<lang haskell>import Data.List ((\\), elemIndex, intersect, nub)
import Control.Arrow ((***), first)
import Data.Bifunctor (bimap, first)


combs 0 _ = [[]]
combs 0 _ = [[]]
Line 2,472: Line 2,472:
| otherwise = foldl makePrecede [] dB
| otherwise = foldl makePrecede [] dB
where
where
dB = ((\(x, y) -> (x, y \\ x)) . (return *** words)) <$> xs
dB = (\(x, y) -> (x, y \\ x)) . bimap return words <$> xs
makePrecede ts ([x], xs) =
makePrecede ts ([x], xs) =
nub $
nub $