This line won't work because "originalstate" is a
string "0" or "1", not numbers 0 or 1.
We can see this in the debug message:
Code: Select all
error: bad argument type - "1"
Function: #<Subr--: #0x55faec0c1bd8>
Arguments:
1
"1"
Function: #<FSubr-SETF: #0x55faec0b92a8>
Arguments:
NEWSTATE
(- 1 ORIGINALSTATE)
Reading Nyquist debug messages is not easy, especially as they don't give line numbers, but reading through this debug message line by line:
- error: bad argument type - "1"
Error: we are passing the string value "1" to a function, which is the wrong data type.
- Function: #<Subr--: #0x55faec0c1bd8>
The function's id is #0x55faec0c1bd8. This isn't very useful, other than it tells us that we are looking into a function ...
- Arguments:
and now the arguments that are being passed to that function...
- 1
The argument being passed to the function...
- "1"
Oh, look, it is a string value "1"
- Function: #<FSubr-SETF: #0x55faec0b92a8>
The containing function's id
- Arguments:
and now the argument list for the containing function...
- NEWSTATE
First argument
- (- 1 ORIGINALSTATE)
Second argument.
The debug error messages start with the fatal error, then work backwards, so we can deduce that:
1. We are passing a string, which is the wrong data type for the function that we are passing it to.
2. The function that we are passing it to (id = #0x55faec0b92a8) has arguments "NEWSTATE" and "(- 1 ORIGINALSTATE)".
So we are looking for the error in a line that looks like:
(
some-function NEWSTATE (- 1 ORIGINALSTATE))
Looking at our code, this line looks very much like the above:
(
setf newstate (- 1 originalstate))
------
Try something like this instead:
Code: Select all
(setf newstate (if (string= originalstate "0") "1" "0"))