sub (Sexp)

    # File lib/sexp.rb, line 243
      def sub(pattern, repl)
        return repl.dup if pattern == self

        done = false

        new = self.map do |subset|
          if done then
            subset
          else
            case subset
            when Sexp then
              if pattern == subset then
                done = true
                repl.dup
              elsif pattern === subset then
                done = true
                subset.sub pattern, repl
              else
                subset
              end
            else
              subset
            end
          end
        end

        return Sexp.from_array(new)
      end