[comp.lang.icon] patch; using string scanning

goer@SOPHIST.UCHICAGO.EDU (Richard Goerwitz) (03/15/90)

I liked the previous posting, and I don't think there was anything
wrong with it.  String scanning just seems a bit clearer to me than
the i/j stuff.  This is how I would have done it:

procedure patch(var,mask)
  text := ""
  var ? {
    every chr := !mask do {
      case chr of {
        "#" : text ||:= move(1)
        "$" : move(1)
        default : text ||:= chr
        }
      }
    }
  return text
end

Warning, warning:  This code fragment has not been tested (though
with Icon it's pretty hard to screw up something of this sort).

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