Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun reshape-image-array-layout (images-array)
- "Reshape an array in the form of:
- #(#(a0 a1 a2 ...) #(b0 b1 b2 ...) ...)
- to
- #(#(a0 b0 ...) #(a1 b1 ...) #(a2 b2 ...) ...)
- and return it."
- (let* ((w (length images-array))
- (h (length (aref images-array 0)))
- (reshaped (map-into (make-array h) (lambda () (make-array w)))))
- (dotimes (i w)
- (dotimes (j h)
- (setf (aref (aref reshaped j) i) (aref (aref images-array i) j))))
- reshaped))
- (reshape-image-array-layout #(#(a0 a1 a2) #(b0 b1 b2) #(c0 c1 c2)))
- --> #(#(a0 b0 c0) #(a1 b1 c1) #(a2 b2 c2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement