Created
May 5, 2010 06:08
-
-
Save fffej/390442 to your computer and use it in GitHub Desktop.
This file contains 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
-- |A simple loop over each pixel | |
forEachPixel :: Grid -> ((Int,Int) -> IO()) -> IO() | |
forEachPixel (Grid n _) = forM_ [(u,v) | u<-[1..n], v <- [1..n]] | |
-- |For simplicity, just consider up,down,left,right to be the neighbours | |
neighbours :: Grid -> (Int,Int) -> IO (Double,Double,Double,Double) | |
neighbours g (x,y) = do | |
up <- readVal g (x-1,y) | |
down <- readVal g (x+1,y) | |
left <- readVal g (x,y-1) | |
right <- readVal g (x,y+1) | |
return (up,down,left,right) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment