[7/27][36/183] Add answers about arrays
[7/27][36/183] Add answers about arrays

:: random insights

-> (dotimes (var count))
dotimes is a short way to do (loop for i below x do (op ...))
(dotimes (x 8) collect x) => (0 1 2 3 4 5 6 70

-> (typep var 'type)
typep is nice to check a type
(typep "string" 'string) => t

-> (progn ... operations)
progn is a macro scope to do anything and later returns the last
evaluation on the end.
(progn (+ 8 5) ( * 1 2)) => 2

:: about arrays

-> how to define
(setf array (make-array '(x y) :initial-content '(content...) :initial-element:
value :adjustable t))

-> get the size of each dimension
(array-dimensions array) => (x y)

-> get the number of dimensions
(array-rank array) => 2

-> get the total of blocks: (reduce * (get-dimensions array))
(array-total-size array) => (* x y)

-> try change the array dimensions if :adjustable t is passed on making
(adjust-array array '(a b))

DestructHub/lisp-koans-answers