Is there any "easy way" to get ((1 2) (3 4)) from #((1 2) (3 4))?
Thanks in advance.
Ferreira wrote:Is there any "easy way" to get ((1 2) (3 4)) from #((1 2) (3 4))?
[1]> #((1 2)(3 4))
#((1 2) (3 4))
[2]> (coerce #((1 2)(3 4)) 'list)
((1 2) (3 4))(defun to-list (2d-array)
(loop for i from 0 below (array-dimension 2d-array 0)
collect (loop for j from 0 below (array-dimension 2d-array 1)
collect (aref 2d-array i j))))
CL-USER> (to-list #2A((1 2)(3 4)))
((1 2) (3 4))
Ferreira wrote:I know I can use the coerce function to make a list from a given array, However, when I give it a multidimensional array I get a list of all elements.
Is there any "easy way" to get ((1 2) (3 4)) from #((1 2) (3 4))?
Thanks in advance.
(make-array '(2 2) :initial-contents '((1 2) (3 4)))
=>
#2A((1 2) (3 4))
Users browsing this forum: No registered users and 2 guests