Problem to update an array
Posted: Tue Mar 16, 2021 9:50 pm
I have the following situation:
Now i want to update a value of the array j:
Using the number 98 works:
Reference with a variable works too:
Why the following expressions raise an error?
Using a string as value works:
Thanks.
Code: Select all
(setq j (array 256 '(-1)))
(setq str "abc")
(char (str 1))
;-> 98
(integer? (char (str 1)))
;-> true
Using the number 98 works:
Code: Select all
(setf (j 98) 2)
;-> 2
Code: Select all
(setq idx (char (str 1)))
;-> 98
(setf (j idx) 2)
;-> 2
Code: Select all
(setf (j (char (str 1))) 2)
;-> ERR: string expected : 2
Code: Select all
(setf (j (char (str 1))) "2")
;-> "2"