(xref object 1 2 3)
to retrieve or set an element. This would be easy to do it aref was a
generic function, but it is not. I describe a simple interface with a
few generic functions (xdims queries dimensions, xtype element type,
etc), any objects that has these methods is called "xrefable".The nice part is that views on an array can also be xrefable. For an
two-dimensional array *a*
,
(slice *a* :all 4)
selects the 4th column of an array.¹ This view is also xrefable, so
you can use(setf (xref (slice *a* :all 4) 2) 9)
to set element 2 to 9
. Changes will be made in the original array
*a*
, since this is a view. But for functions that just expect an
array, they can use the interface (xref, xdims, etc) and not care
where it is coming from.¹ The slice interface is similar to author's affi package, but now arbitrary index vectors are allowed.
Homepage: https://github.com/blindglobe/xarray
License: MIT
See Also: cl-slice
Topics: language extension