1.2.3-SNAPSHOT Arrow_down_16x16

grid-apply

incanter.core

  • (grid-apply f x-min x-max y-min y-max)
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.

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source incanter/core.clj:2607 top

(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))))
Vars in incanter.core/grid-apply: defn let reduce
Used in 0 other vars

Comments top

No comments for grid-apply. Log in to add a comment.