How can I remove a certain character from a string in Nyquist (which is very similar to xlisp) and have the result returned?
I want to count how many "A" there are in a string like "ABBAAAABBBAABAAAB". (Yes, there are only 'A's and 'B's in the string.)
Since there is no (count) function in Nyquist I tried something like
(length (remove #\B mystring))
or
(length (remove #\B mystring :test equal))
But it doesn't work.
Forgetting the character count for a moment, how can I remove the 'B's from the string?
Will there always be only
As andBs in the string? If not, you might want to do something likeAccording to the XLISP reference for
remove, the Nyquistremovedoesn't deal withstrings, onlylists. You need to convert astringto alistin order to operate on it this way, but there's nocoerceeither. It's a touch hacky, but the easiest way around it I see is to stream astringandread-charit. This will produce alistofchars that you can then manipulate withremove.It should now be possible to