Posted By

deepsoul on 03/18/10


Tagged

box integer rectangle interval


Versions (?)

Interval of integral points


 / Published in: Haskell
 

These functions return all points (pairs or triples of coordinates) within a given rectangle or box. pam is the reverse map function which was defined here.

  1. rect :: Int -> Int -> [[(Int,Int)]]
  2. rect a b = map (pam $ map (,) [1..a]) [1..b]
  3.  
  4. box :: Int -> Int -> Int -> [[[(Int,Int,Int)]]]
  5. box a b c = map (pam . map pam $ map (pam $ map (,,) [1..a]) [1..b]) [1..c]

Report this snippet  

You need to login to post a comment.