Replaces all occurrences of 'oldval' with 'newval', recursively.

Usage:   replace (inlst,oldval,newval)
437741
def replace (inlst,oldval,newval):
    
    lst = inlst*1
    for i in range(len(lst)):
        if type(lst[i]) not in [ListType,TupleType]:
            if lst[i]==oldval: lst[i]=newval
        else:
            lst[i] = replace(lst[i],oldval,newval)
    return lst
64673
public void replaceWithNewInstances(Collection<SSTableReader> toReplace, Collection<SSTableReader> replaceWith)
    {
        replaceReaders(toReplace, replaceWith, true);
    }
62823
function replace (obj, key, val) {
  if (obj.hasOwnProperty(key)) obj[key] = val;
  return obj;
}
361049
function(newval, oldval) {
		if ([newval, oldval].every(function(val) {
			return val.contains('edbml.$');
		})) {
			var newkeys = gui.KeyMaster.extractKey(newval);
			var oldkeys = gui.KeyMaster.extractKey(oldval);
			if (newkeys && oldkeys) {
				oldkeys.forEach(function(oldkey, i) {
					var newkey = newkeys[i];
					newval = newval.replace(newkey, '');
					oldval = oldval.replace(oldkey, '');
					this._functions[oldkey] = newkey;
				}, this);
				return newval === oldval;
			}
		}
		return false;
	}
512155
function replaceOutputPlaceholders(source, value) {
		var ranges = locateOutputPlaceholder(source);
		
		ranges.reverse().forEach(function(r) {
			source = utils.replaceSubstring(source, value, r);
		});
		
		return source;
	}
1201792
private V replaceValue(Node<V> node, V newValue) {
        // Note: a node is terminal if it already has a value
	if (node.isTerminal()) {
	    V old = node.value;
	    node.value = newValue;
	    return old;
	}
	// the node wasn't already a terminal node (i.e. this char sequence is a
	// substring of an existing sequence), assign it a value
	else {
	    node.value = newValue;
	    size++;
	    return null; // no old value
	}
    }
629273
private Map<String, String> replaceInMapValues(Map<String, String> map,
                                                   String oldVal,
                                                   String newVal) {
        for (String key : map.keySet()) {
            String value = map.get(key);
            if (value.contains(oldVal)) {
                value = StringUtils.replace(value, oldVal, newVal);
                map.put(key, value);
            }
        }
        return map;
    }
1241344
def replace_name(expr: AST, old_name: str, new_name: str) -> AST:
    """"""
    return _NameReplacer(old_name, new_name).visit(deepcopy(expr))
1071539
def rewrite_str_with_trie(sval, trie, boundaries = False, slow = False):
    '''
    
    '''
    if boundaries:
        sval = fsed.ahocorasick.boundary_transform(sval)
    if slow:
        sval = trie.replace(sval)
    else:
        sval = trie.greedy_replace(sval)
    if boundaries:
        sval = ''.join(fsed.ahocorasick.boundary_untransform(sval))
    return sval
261409
def replace(self, new):
        """"""
        assert self.parent is not None, str(self)
        assert new is not None
        if not isinstance(new, list):
            new = [new]
        l_children = []
        found = False
        for ch in self.parent.children:
            if ch is self:
                assert not found, (self.parent.children, self, new)
                if new is not None:
                    l_children.extend(new)
                found = True
            else:
                l_children.append(ch)
        assert found, (self.children, self, new)
        self.parent.changed()
        self.parent.children = l_children
        for x in new:
            x.parent = self.parent
        self.parent = None
181309
function replaceAt(items, item, index) {
  var copy = items.slice();
  copy.splice(index, 1, item);
  return copy;
}
533239
private static Node<Container> replace(Node<Container> list, Container old, AbstractConfigValue replacement) {
        Container child = list.head();
        if (child != old)
            throw new ConfigException.BugOrBroken("Can only replace() the top node we're resolving; had " + child
                    + " on top and tried to replace " + old + " overall list was " + list);
        Container parent = list.tail() == null ? null : list.tail().head();
        if (replacement == null || !(replacement instanceof Container)) {
            if (parent == null) {
                return null;
            } else {
                /*
                 * we are deleting the child from the stack of containers
                 * because it's either going away or not a container
                 */
                AbstractConfigValue newParent = parent.replaceChild((AbstractConfigValue) old, null);

                return replace(list.tail(), parent, newParent);
            }
        } else {
            /* we replaced the container with another container */
            if (parent == null) {
                return new Node<Container>((Container) replacement);
            } else {
                AbstractConfigValue newParent = parent.replaceChild((AbstractConfigValue) old, replacement);
                Node<Container> newTail = replace(list.tail(), parent, newParent);
                if (newTail != null)
                    return newTail.prepend((Container) replacement);
                else
                    return new Node<Container>((Container) replacement);
            }
        }
    }
736705
def replace(self, re_text, replace_str, text):
        
        return re.sub(re_text, replace_str, text)
8429
function replace(oldNode, newNode){
    return oldNode[PARENT_NODE] ? oldNode[PARENT_NODE].replaceChild(newNode, oldNode) : oldNode;
  }
476112
public static final double[] replaceValues(double[] v, double oldValue,	double newValue) {
		double[] ret = new double[v.length];
		for (int i = 0; i < v.length; i++) {
			double vi = v[i];
			if (Double.compare(oldValue, vi) != 0) {
				// no substitution
				ret[i] = vi;
			} else {
				ret[i] = newValue;
			}
		}
		return ret;
	}
712914
function replace(a, elt1, elt2) {
  var idx = a.indexOf(elt1);
  if (idx !== -1) { a[idx] = elt2; }
  return a;
}
1065145
public static String replace(String str, String search, String replace) {
        if (str == null || search == null || replace == null) {
            return str;
        }
        StringBuilder sb = new StringBuilder();
        int searchLen = search.length();
        int stringLen = str.length();
        int oldIndex = 0;
        int index;
        while ((index = str.indexOf(search, oldIndex)) >= 0) {
            sb.append(str, oldIndex, index);
            sb.append(replace);
            oldIndex = index + searchLen;
        }
        if (oldIndex < stringLen) {
            sb.append(str, oldIndex, stringLen);
        }
        return sb.toString();
    }