Skip to content

Instantly share code, notes, and snippets.

@msgodf
Created December 10, 2012 15:06
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 msgodf/4251107 to your computer and use it in GitHub Desktop.
Save msgodf/4251107 to your computer and use it in GitHub Desktop.
Generate all pairs of the integers [0,n), excluding those of the form [a,a] and only the first pair of the symmetric [a,b] [b,a]
(defn different-int-pairs
"Generate all pairs of the integers [0,n), excluding those of the form [a,a] and only the first pair of the symmetric [a,b] [b,a]"
[n]
(mapcat (fn [x] (map #(vector x %)
(range (inc x) n)))
(range n)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment