I’d like to make copies of my 2D array, which feels like the nice, functional, nondestructive way of handling arrays. What is the lispy way of doing this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
UPDATE: Nowadays, alexandria has a
copy-arrayvery similar to the implementation given below. Use that.OBSOLETE ANSWER: I used the following, which I believed was better than the alexandria version at the time:
The problem with the alexandria version was that the
adjust-arrayhack causes the result (at least on SBCL) to never be a
simple-array, which some other libraries (e.g. opticl) expect. Theabove version also was faster for me.
Someone else has published a very similar version in a different
library, but I forgot the names of both person and library.