Interval of integral points


/ Published in: Haskell
Save to your folder(s)

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](http://snipplr.com/view/18351/reverse-map/).


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.