(defn grid-apply
" Applies the given function f, that accepts two arguments, to a grid
defined by rectangle bounded x-min, y-min, x-max, y-max and returns a
sequence of three sequences representing the cartesian product of x and y
and z calculated by applying f to the combinations of x and y."
([f x-min x-max y-min y-max]
(let [x-vals (range x-min x-max (/ (- x-max x-min) 100))
y-vals (range y-min y-max (/ (- y-max y-min) 100))
xyz (for [_x x-vals _y y-vals] [_x _y (f _x _y)])
transpose #(list (conj (first %1) (first %2))
(conj (second %1) (second %2))
(conj (nth %1 2) (nth %2 2)))]
(reduce transpose [[] [] []] xyz))))

Used in 0 other vars

## Comments top

## No comments for

grid-apply. Log in to add a comment.