Advertisement
Guest User

Untitled

a guest
Dec 21st, 2018
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. (defun reshape-image-array-layout (images-array)
  2. "Reshape an array in the form of:
  3. #(#(a0 a1 a2 ...) #(b0 b1 b2 ...) ...)
  4. to
  5. #(#(a0 b0 ...) #(a1 b1 ...) #(a2 b2 ...) ...)
  6. and return it."
  7. (let* ((w (length images-array))
  8. (h (length (aref images-array 0)))
  9. (reshaped (map-into (make-array h) (lambda () (make-array w)))))
  10. (dotimes (i w)
  11. (dotimes (j h)
  12. (setf (aref (aref reshaped j) i) (aref (aref images-array i) j))))
  13. reshaped))
  14. (reshape-image-array-layout #(#(a0 a1 a2) #(b0 b1 b2) #(c0 c1 c2)))
  15. --> #(#(a0 b0 c0) #(a1 b1 c1) #(a2 b2 c2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement