[comp.lang.icon] strip?

goer@SOPHIST.UCHICAGO.EDU (Richard Goerwitz) (01/20/90)

A snail asked:

The question I have is:  What is the best way to elminate spaces (or, to
generalize, members of a particular cset) from a string while still preserving
the order of the remaining characters?

I wonder if you are referring to a stripping routine?

procedure Strip(s,c)
  s2 := ""
  s ? {
    while s2 ||:= tab(upto(c))
    do tab(many(c))
    s2 ||:= tab(0)
    }
  return s2
end

This will work with strings, and I suppose that type conversion
will make it work with csets, too.  For operations specifically
having to do with csets, you can of course say

     c1 --:= c2

where c1 is the cset you are trying to strip down, and c2 is the
cset containing the characters to be removed from it.  The trouble
here, though, is that, unlike strings, csets are not an ordered
sequence of characters (you did say something about "original or-
der," didn't you?).

I guess I'm confused.  If the original order is important, use 
Strip(s,c), and feed it strings.  Does this help?

                                        -Richard L. Goerwitz
                                        goer@sophist.uchicago.edu
                                        goer%sophist@uchicago.bitnet
                                        rutgers!oddjob!gide!sophist!goer