Delete cruft, add Reader monad to some internal ai
This commit is contained in:
+8
-6
@@ -1,18 +1,20 @@
|
||||
module Dodge.Graph
|
||||
where
|
||||
import Data.Function (on)
|
||||
import Data.List
|
||||
import Data.List.Extra
|
||||
|
||||
import Data.Bifunctor (first)
|
||||
import Data.Graph
|
||||
import Data.Maybe
|
||||
|
||||
pairsToIncidence :: (Eq a,Ord a) => [(a,a)] -> [(a,[a])]
|
||||
pairsToIncidence = map ((\(xs,ys) -> (head xs,ys)) . unzip)
|
||||
. groupBy ( (==) `on` fst)
|
||||
. sort
|
||||
pairsToIncidence
|
||||
= map (first head . unzip)
|
||||
. groupOn fst
|
||||
. sort
|
||||
|
||||
incidenceToFunction :: Eq a => [(a,[a])] -> a -> [a]
|
||||
incidenceToFunction xs a = case lookup a xs of Just ys -> ys
|
||||
Nothing -> []
|
||||
incidenceToFunction xs a = fromMaybe [] $ lookup a xs
|
||||
|
||||
mkNode :: (a,[a]) -> (a,a,[a])
|
||||
mkNode (x,xs) = (x,x,xs)
|
||||
|
||||
Reference in New Issue
Block a user