Home > Blockchain >  Can't access a specific element in a 2D Matrix represented as a List of Lists
Can't access a specific element in a 2D Matrix represented as a List of Lists

Time:02-10

I am trying to access a specific element in a 2D Matrix represented as list of Lists so I can set that specific element to 0. However, when I run the code below:

(defvar listOfLists '( (1 3) (2 6) ))
(defvar referenceToTopLeftCorner (elt 0 (elt 0 listOfLists)))
(setq referenceToTopLeftCorner 0)
(print (format nil "listsOfLists = ~a" listOfLists))

The following output is:

"- ELT: 0 is not a SEQUENCE"

This seems strange, as I thought that the ELT method can be used to get values within a list?

CodePudding user response:

Wrong argument order for elt:

elt sequence index => object

  • Related