Created
July 26, 2014 11:13
-
-
Save fffej/ca5b93da956f8bb6842e to your computer and use it in GitHub Desktop.
WarpingPath
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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