
12 Dec
2012
12 Dec
'12
3:54 p.m.
I found a nice idiom for a graph algorithm where the pairs of nodes representing links could be merged into node lists by something like: ns = nub $ map fst g --head nodes ne = nub $ map snd g -- tail nodes And found a nicer approach: (ns,ne) = (nub***nub) unzip g Or perhaps: (ns.ne) = bimap nub nub $ unzip g -- from Control.Bifunctor The SO reference I saw described bimap as a way to map a function over a pair, and it seemed like a great match, but I cannot find the bimap function, and cabal reports no package Control.Bifunctor. ?? -------------------------------------------------------