Skip to content

Instantly share code, notes, and snippets.

@seantalts
Created June 15, 2016 02:15
Show Gist options
  • Save seantalts/a559ab62c9a238a0055e17c27957274a to your computer and use it in GitHub Desktop.
Save seantalts/a559ab62c9a238a0055e17c27957274a to your computer and use it in GitHub Desktop.
dim mat = (length mat, length (head mat))
subMats mat (height, width) =
[trimmed | r <- [0..rows]
, c <- [0..columns]
, let vertTrimmed = take height (drop r mat)
trimmed = map (take width . drop c) vertTrimmed
, length trimmed == height
, length (head trimmed) == width]
where (rows, columns) = dim mat
matContains mat p = elem p subs
where subs = subMats mat $ dim p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment