Made these "proper" macros that mimic the sequence map because I didn't like vectorize's need for symbols.
(defmacromap-array-into (dest fun &rest arrays)
"map for arrays. Only the arrays' total-size must be equal."
(assert arrays () "map-array-into needs at least one array argument")
(let ((array-num (length arrays)))
(once-only (dest (arrays ``(,,@arrays)))
`(iter
(initially (assert (apply#'= (array-total-size,dest) (mapcar#'array-total-size,arrays))
() "map-array-into array arguments must have the same total size"))
(for i below (array-total-size (car,arrays)))
(with arrays-vec = (coerce,arrays 'vector))
(setf (row-major-aref,dest i)
(funcall,fun
,@(iter (for i below array-num)
(collect `(row-major-aref (aref arrays-vec ,i) i)))))
(finally (return,dest))))))
(defmacromap-array (fun &rest arrays)
"map for arrays. Only the arrays' total-size must be equal.The resulting array uses the dimensions of the first array parameter."
(assert arrays () "map-array needs at least one array argument")
(let ((array-num (length arrays)))
(once-only ((arrays ``(,,@arrays)))
`(iter
(initially (assert (apply#'= (mapcar#'array-total-size,arrays))
() "map-array array arguments must have the same total size"))
(with ret = (make-array (array-dimensions (car,arrays))))
(for i below (array-total-size (car,arrays)))
(with arrays-vec = (coerce,arrays 'vector))
(setf (row-major-aref ret i)
(funcall,fun
,@(iter (for i below array-num)
(collect `(row-major-aref (aref arrays-vec ,i) i)))))
(finally (return ret))))))
would you be interested? If so, I'd convert iter to loop and make a PR. I also plan on making an array version for all the relevant sequence functions (substitute, count, find, position, replace, fill, etc...).
Made these "proper" macros that mimic the sequence map because I didn't like vectorize's need for symbols.
would you be interested? If so, I'd convert iter to loop and make a PR. I also plan on making an array version for all the relevant sequence functions (substitute, count, find, position, replace, fill, etc...).