Skip to content

Instantly share code, notes, and snippets.

@fffej fffej/WarpingPath.hs
Created Jul 26, 2014

Embed
What would you like to do?
WarpingPath
warpingPath :: Array (Int,Int) Int -> [(Int,Int)]
warpingPath arr = go (w,h) []
where
(_,(w,h)) = bounds arr
go p@(x,y) xs
| x == 0 && y == 0 = p : xs
| otherwise = go minVal (minVal : xs)
where
minVal = minimumBy (comparing (arr !)) [down,downLeft,left]
down = (max 0 (x-1),max 0 y)
left = (x,max 0 (y-1))
downLeft = (max 0 (x-1),max 0 (y-1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.