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
A
s andB
s in the string? If not, you might want to do something likeAccording to the XLISP reference for
remove
, the Nyquistremove
doesn't deal withstring
s, onlylist
s. You need to convert astring
to alist
in order to operate on it this way, but there's nocoerce
either. It's a touch hacky, but the easiest way around it I see is to stream astring
andread-char
it. This will produce alist
ofchar
s that you can then manipulate withremove
.It should now be possible to