def substitute(ary, from, to)
      res = ary.dup
      i = 0
      while i < res.size
        if res[i...i + from.size] == from
          res[i...i + from.size] = to
        end
        i += 1
      end
      res
    end
def substitute(ary, from, to)
      res = ary.dup
      i = 0
      while i < res.size
        if res[i...i + from.size] == from
          res[i...i + from.size] = to
        end
        i += 1
      end
      res
    end
Substitutes a sub-array of one array with another sub-array.

 @param ary [Array] The array in which to make the substitution
 @param from [Array] The sequence of elements to replace with `to`
 @param to [Array] The sequence of elements to replace `from` with