Fork me on GitHub
#code-reviews
<
2016-08-19
>
amacdougall21:08:43

I'm generating a grid as a two-dimensional array. I've got two equivalent functions, which both look awful:

(defn grid-mapv [w h]
  (mapv
    (fn [x]
      (mapv
        (fn [y] [x y])
        (range 0 w)))
    (range 0 h)))

(defn grid-for [w h]
 (into [] (for [x (range 0 w)]
            (into [] (for [y (range 0 h)]
                       [x y])))))

amacdougall21:08:49

Is there a better way?

amacdougall21:08:11

I'm sure I can improve the formatting by defining a couple of things in lets or whatever.