Skip to content

Instantly share code, notes, and snippets.

@aterreno
Created February 4, 2011 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aterreno/811226 to your computer and use it in GitHub Desktop.
Save aterreno/811226 to your computer and use it in GitHub Desktop.
n by n wavefront matrix
wavefront :: Int -> Array (Int,Int) Int
wavefront n = a where
a = array ((1,1),(n,n))
([((1,j), 1) | j <- [1..n]] ++
[((i,1), 1) | i <- [2..n]] ++
[((i,j), a!(i,j-1) + a!(i-1,j-1) + a!(i-1,j))
| i <- [2..n], j <- [2..n]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment