(save) + arrays

Q&A's, tips, howto's
Locked
kunt
Posts: 2
Joined: Wed Oct 10, 2012 1:41 pm

(save) + arrays

Post by kunt »

hello.

it looks like (save) does not handle arrays correctly.
i have a 3-dimensional array and want to save it to a file for further re-initialization, but it fails.

what i get after (save) in a file:

Code: Select all

(set 'world-root (array 1 1 1 (flat '(
  (((nil 1 "data/maps/start.lisp")))))))
and if we eval this we get:

> (set 'world-root (array 1 1 1 (flat '((((nil 1 "data/maps/start.lisp")))))))
(((nil)))


which is not correct.
any suggestions?

ps: newlisp-10.4.3

johu
Posts: 143
Joined: Mon Feb 08, 2010 8:47 am

Re: (save) + arrays

Post by johu »

I don't know what your 3-dimensional array is meaning, sorry.
But I think

Code: Select all

> (set 'world-root (array 3 (flat '((((nil 1 "data/maps/start.lisp")))))))
(nil 1 "data/maps/start.lisp")
Or following?

Code: Select all

> (set 'world-root (array 3 1 1 (flat '((((nil 1 "data/maps/start.lisp")))))))
(((nil)) ((1)) (("data/maps/start.lisp")))
> (set 'world-root (array 1 3 1 (flat '((((nil 1 "data/maps/start.lisp")))))))
(((nil) (1) ("data/maps/start.lisp")))
> (set 'world-root (array 1 1 3 (flat '((((nil 1 "data/maps/start.lisp")))))))
(((nil 1 "data/maps/start.lisp")))

kunt
Posts: 2
Joined: Wed Oct 10, 2012 1:41 pm

Re: (save) + arrays

Post by kunt »

i initialize 3-dimensional array w/ only one element, as follows:
(define world-root (array 1 1 1 (list world-new-entry)))
the number of elements is being increased during the program execution. every element is a list.
and even this simple situation does not work.

for now i switched to lists entirely, they perform much better, after serialization i get:

Code: Select all

(set 'world-root '(
  (((nil 1 "data/maps/start.lisp")))))

Locked