Last active
January 1, 2016 12:08
-
-
Save johnwalker/8142143 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns play.grids) | |
(defprotocol Grid | |
(select-by-row [x r]) | |
(select-by-col [x c]) | |
(print [x])) | |
(defrecord GridSize [vvs] | |
Grid | |
(select-by-row [x r] | |
(nth vvs r)) | |
(select-by-col [x c] | |
(map #(nth % c) vvs)) | |
(print [x] | |
(doseq [x vvs] (println x)))) | |
(-> [[1 2 3] [4 5 6] [7 8 9]] | |
GridSize. | |
(select-by-col 0)) | |
(-> [[1 2 3] [4 5 6] [7 8 9]] | |
GridSize. | |
(select-by-row 0)) | |
(-> [[1 2 3] [4 5 6] [7 8 9]] | |
GridSize. | |
print) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment