Code: Select all
(set 'randomMatrix (array 3 5 '(nil)))
(dotimes (x 3)
(dotimes (y 5)
(setf (randomMatrix x y) (rand 10))))
(ref '0 randomMatrix)
ERR: list expected in function ref : ((8 3 7 7 9) (1 3 7 2 5) (4 6 3 5 9) (9 6 7 1 6) (0 2 1 8 1))
So I changed last line to:
Code: Select all
(ref '0 (array-list randomMatrix))
I get this:
> randomMatrix
((8 3 7 7 9) (1 3 7 2 5) (4 6 3 5 9) (9 6 7 1 6) (0 2 1 8 1))
> (array-list randomMatrix)
((8 3 7 7 9) (1 3 7 2 5) (4 6 3 5 9) (9 6 7 1 6) (0 2 1 8 1))
It took me some time to think they might not be the same thing internally and to discover it by asking in the REPL:
Code: Select all
> (array? randomMatrix)
true
> (list? randomMatrix)
nil
On a side note I was expecting random numbers, but every run spits the same stuff. I realize there must be some initialization going on somewhere (didn't look for it yet). But I think most people expects random stuff to be random and when the need to make a repeatable pseudo-random stuff arise, only then use some pre-seeded function.