RosettaCodeData/Task/Floyd-Warshall-algorithm/Haskell/floyd-warshall-algorithm-5.hs
2023-07-01 13:44:08 -04:00

7 lines
258 B
Haskell

buildPaths d = mapWithKey (\pair s -> s { path = buildPath pair}) d
where
buildPath (i,j)
| i == j = [[j]]
| otherwise = do k <- path $ fromJust $ lookup (i,j) d
p <- buildPath (k,j)
[i : p]