Skip to content

Instantly share code, notes, and snippets.

@FrozenCow
Created July 6, 2013 17:36
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 FrozenCow/5940616 to your computer and use it in GitHub Desktop.
Save FrozenCow/5940616 to your computer and use it in GitHub Desktop.
(ns hello
(:require-macros
[macros :as macros]
)
)
; ...
(macros/indexMatrix 4 4 i x y (+ (fieldGet x y) i))
; ...
(ns macros)
(defmacro indexMatrix
[width height i x y body]
`(let [length# (* ~width ~height)]
(doseq [i# (range length#)]
(let [~i i#
~x (rem i# ~width)
~y (quot i# ~width)
]
)
(do ~@body)
)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment