Skip to content

Instantly share code, notes, and snippets.

@sudowork
Last active December 16, 2015 06:49
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 sudowork/5394282 to your computer and use it in GitHub Desktop.
Save sudowork/5394282 to your computer and use it in GitHub Desktop.
; use list comprehension to get a list of chess squares
user=> (for [x (range 1 9), y (range 1 9)] [x y])
([1 1] [1 2] [1 3] [1 4] [1 5] [1 6] [1 7] [1 8] [2 1] [2 2] [2 3] [2 4] [2 5] [2 6] [2 7] [2 8] [3 1] [3 2] [3 3] [3 4] [3 5] [3 6] [3 7] [3 8] [4 1] [4 2] [4 3] [4 4] [4 5] [4 6] [4 7] [4 8] [5 1] [5 2] [5 3] [5 4] [5 5] [5 6] [5 7] [5 8] [6 1] [6 2] [6 3] [6 4] [6 5] [6 6] [6 7] [6 8] [7 1] [7 2] [7 3] [7 4] [7 5] [7 6] [7 7] [7 8] [8 1] [8 2] [8 3] [8 4] [8 5] [8 6] [8 7] [8 8])
; apply a filter using the :when keyword
user=> (for [x (range 1 9), y (range 1 9), :when (= x y)] [x y])
([1 1] [2 2] [3 3] [4 4] [5 5] [6 6] [7 7] [8 8])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment