Problem to update an array

Q&A's, tips, howto's
Locked
cameyo
Posts: 183
Joined: Sun Mar 27, 2011 3:07 pm
Location: Italy
Contact:

Problem to update an array

Post by cameyo »

I have the following situation:

Code: Select all

(setq j (array 256 '(-1)))
(setq str "abc")
(char (str 1))
;-> 98
(integer? (char (str 1)))
;-> true
Now i want to update a value of the array j:
Using the number 98 works:

Code: Select all

(setf (j 98) 2)
;-> 2
Reference with a variable works too:

Code: Select all

(setq idx (char (str 1)))
;-> 98
(setf (j idx) 2)
;-> 2
Why the following expressions raise an error?

Code: Select all

(setf (j (char (str 1))) 2)
;-> ERR: string expected : 2
Using a string as value works:

Code: Select all

(setf (j (char (str 1))) "2")
;-> "2"
Thanks.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: Problem to update an array

Post by Lutz »

This is fixed here: http://www.newlisp.org/downloads/develo ... nprogress/

Was a bug in 'char' when used by 'setf'.

cameyo
Posts: 183
Joined: Sun Mar 27, 2011 3:07 pm
Location: Italy
Contact:

Re: Problem to update an array

Post by cameyo »

Thanks.
When will be released a compiled version?
Best regards,
cameyo

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: Problem to update an array

Post by Lutz »

At the moment I only can compile on FreeBSD 12.2 (Intel CPU), OpenBSD 5.5 (amd64 CPU) and MacOS 11.2.2 (Intel).
No access to Windows or Linux at the moment. What do your need?

cameyo
Posts: 183
Joined: Sun Mar 27, 2011 3:07 pm
Location: Italy
Contact:

Re: Problem to update an array

Post by cameyo »

Windows and MacOS. But I can wait without any problems.
Thank you.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: Problem to update an array

Post by Lutz »

You can find a macOS executable here:
http://www.newlisp.org/downloads/develo ... ess/macOS/

cameyo
Posts: 183
Joined: Sun Mar 27, 2011 3:07 pm
Location: Italy
Contact:

Re: Problem to update an array

Post by cameyo »

Very nice.
Thank you.

Locked