this mutates passed in ex (any BaseX), replacing nested selects with their (flattened) output
558531
def replace_subqueries(ex,tables,table_ctor):
  ""
  # http://www.postgresql.org/docs/9.1/static/sql-expressions.html#SQL-SYNTAX-SCALAR-SUBQUERIES
  # see here for subquery conditions that *do* use multi-rows. ug. http://www.postgresql.org/docs/9.1/static/functions-subquery.html
  if isinstance(ex,sqparse2.SelectX):
    old_tables, ex.tables = ex.tables, [] # we *don't* recurse into tables because selects in here get transformed into tables
  for path in treepath.sub_slots(ex, lambda x:isinstance(x,sqparse2.SelectX)):
    ex[path] = sqparse2.Literal(flatten_scalar(run_select(ex[path], tables, table_ctor)))
  if isinstance(ex,sqparse2.SelectX): ex.tables = old_tables
  return ex
988785
def create_selection():
    
    operation = Forward()
    nested = Group(Suppress("(") + operation + Suppress(")")).setResultsName("nested")
    select_expr = Forward()
    functions = select_functions(select_expr)
    maybe_nested = functions | nested | Group(var_val)
    operation <<= maybe_nested + OneOrMore(oneOf("+ - * /") + maybe_nested)
    select_expr <<= operation | maybe_nested
    alias = Group(Suppress(upkey("as")) + var).setResultsName("alias")
    full_select = Group(
        Group(select_expr).setResultsName("selection") + Optional(alias)
    )
    return Group(
        Keyword("*") | upkey("count(*)") | delimitedList(full_select)
    ).setResultsName("attrs")
1092044
function mutable(/* a[, b[, ...]] */)
{
  var args   = Array.prototype.slice.call(arguments)
    , result = args.shift()
    ;

  while (args.length)
  {
    result = merge.call(this, result, args.shift());
  }

  return result;
}
535814
def replace_strings_in_list(array_of_strigs, replace_with_strings):
    ""
    potentially_nested_list = [replace_with_strings.get(s) or s for s in array_of_strigs]
    return list(flatten(potentially_nested_list))
1301098
def result_tree_flat(context, cl, request):
    

    return {
        #'filtered': is_filtered_cl(cl, request),
        'results': (th_for_result(cl, res) for res in list(cl.result_list)),
    }
1165840
def _nested_output(obj):
    '''
    
    '''
    nested.__opts__ = __opts__
    ret = nested.output(obj).rstrip()
    return ret
90828
def flatten_tree(test, enumerator, exp):
  
  return sum((flatten_tree(test, enumerator, subx) for subx in enumerator(exp)), []) if test(exp) else [exp]
346311
function(_exps,_out){
        // foo|a:x|b:y1,y2|c:z1,z2 -> c(b(a(foo,x),y1,y2),z1,z2)
        if (!_exps||!_exps.length) return;
        if (_exps.length==1){
            var _var = _exps.pop();
            _doParseVars(_var);
            // fix error for ${}
            _out.push(_var==''?'""':_var);
            return;
        }
        var _exp = _exps.pop().split(':');
        _out.push('__MDF[\''+_exp.shift()+'\'](');
        _doParseExpression(_exps,_out);
        if (_exp.length>0){
            var _args = _exp.join(':');
            _doParseVars(_args);
            _out.push(','+_args);
        }
        _out.push(')');
    }
1351821
function flatten(source) {
  var output = {};

  function step(object, prev) {
    for (var key in object) {
      if (has.call(object, key)) {
        var value = object[key];
        var newKey = prev ? prev + ' ' + key : key;

        if (!is.array(value) && is.object(value)) {
          return step(value, newKey);
        }

        output[newKey] = value;
      }
    }
  }

  step(source);

  return output;
}
663176
function executeArrayMutation(state, payload, action) {
      var newValue, pathWithIds;

      if (!PROP_SUBPROP.includes('*')) {
        newValue = payload;
        pathWithIds = PROP_SUBPROP;
      } else {
        if (!isArray(payload) && action !== 'splice') payload = [payload];
        if (action !== 'pop' && action !== 'shift') newValue = payload.pop();
        var ids = getIdsFromPayload(payload, conf, PROP_SUBPROP);
        if (!checkIdWildcardRatio(ids, PROP_SUBPROP, conf)) return;
        pathWithIds = fillinPathWildcards(ids, PROP_SUBPROP, state, conf);
      }

      if (action === 'push') {
        return pushDeepValue(state, pathWithIds, newValue);
      }

      if (action === 'pop') {
        return popDeepValue(state, pathWithIds);
      }

      if (action === 'shift') {
        return shiftDeepValue(state, pathWithIds);
      }

      if (action === 'splice') {
        return spliceDeepValue.apply(void 0, [state, pathWithIds].concat(_toConsumableArray(newValue)));
      }
    }
1293570
private <T> Collection<Integer> transformSelect(SelectTransformation<T> select) {
		StreamTransformation<T> input = select.getInput();
		Collection<Integer> resultIds = transform(input);

		// the recursive transform might have already transformed this
		if (alreadyTransformed.containsKey(select)) {
			return alreadyTransformed.get(select);
		}

		List<Integer> virtualResultIds = new ArrayList<>();

		for (int inputId : resultIds) {
			int virtualId = StreamTransformation.getNewNodeId();
			streamGraph.addVirtualSelectNode(inputId, virtualId, select.getSelectedNames());
			virtualResultIds.add(virtualId);
		}
		return virtualResultIds;
	}
1024493
function ImmutableCoreModelSelect (args) {
    // create select object to store state of select
    var select = {}
    // model query will be performed on
    select.model = args.model
    // current context of query
    select.context
    // data associated with context
    select.contextData = {}
    // true if next property access should be column name
    select.expectColumn = false
    // all properties
    select.history = []
    // query to be performed
    select.query = {
        session: args.session,
    }
    // create proxy to map property accesses to query builder commands
    select.proxy = new Proxy({}, {
        // proxy handler with get function that passes select object
        // along with the requested property to the actual handler
        get: function (target, property) {
            return getProxy(select, property)
        }
    })
    // return proxy
    return select.proxy
}
1237336
def mutate(self, chromosomes, p_mutate):
        
        assert 0 <= p_mutate <= 1
        
        for chromosome in chromosomes:
            chromosome.mutate(p_mutate)
1134676
def replace_nil_binds(sql, args)
      nils = []
      args.each_with_index { |value, i| nils << i if value.nil? }
      unless nils.empty? then
        logger.debug { "SQL executor working around RDBI bug by eliminating the nil arguments #{nils.to_series} for the SQL:\n#{sql}..." }
        # Quoted ? is too much of a pain for this hack; bail out.
        raise ArgumentError.new("RDBI work-around does not support quoted ? in transactional SQL: #{sql}") if sql =~ /'[^,]*[?][^,]*'/
        prefix, binds_s, suffix = /(.+\s*values\s*\()([^)]*)(\).*)/i.match(sql).captures
        sql = prefix
        binds = binds_s.split('?')
        last = binds_s[-1, 1]
        del_cnt = 0
        binds.each_with_index do |s, i|
          sql << s
          if nils.include?(i) then
            args.delete_at(i - del_cnt)
            del_cnt += 1
            sql << 'NULL'
          elsif i < binds.size - 1 or last == '?'
            sql << '?'
          end
        end
        sql << suffix
      end
      logger.debug { "SQL executor converted the SQL to:\n#{sql}\nwith arguments #{args.qp}" }
      return args.unshift(sql)
    end
920682
def mutate_stream (instream, outstream):
    """"""

    chunk = None
    key = None
    data = None
    misclines = []

    for fullline in instream:
        line = fullline.split ('#', 1)[0]

        m = sectionre.match (line)
        if m is not None:
            # New chunk
            if chunk is not None:
                if key is not None:
                    chunk.data.set_one (key, data.strip ().decode ('utf8'))
                    key = data = None
                yield chunk
                chunk.emit (outstream)

            chunk = FileChunk ()
            for miscline in misclines:
                chunk._addLine (miscline, None)
            misclines = []
            chunk.data.section = m.group (1)
            chunk._addLine (fullline, None)
            continue

        if len (line.strip ()) == 0:
            if key is not None:
                chunk.data.set_one (key, data.strip ().decode ('utf8'))
                key = data = None
            if chunk is not None:
                chunk._addLine (fullline, None)
            else:
                misclines.append (fullline)
            continue

        m = escre.match (fullline)
        if m is not None:
            if chunk is None:
                raise InifileError ('key seen without section!')
            if key is not None:
                chunk.data.set_one (key, data.strip ().decode ('utf8'))
            key = m.group (1)
            data = m.group (2).replace (r'\"', '"').replace (r'\n', '\n').replace (r'\\', '\\')
            chunk.data.set_one (key, data.decode ('utf8'))
            chunk._addLine (fullline, key)
            key = data = None
            continue

        m = keyre.match (line)
        if m is not None:
            if chunk is None:
                raise InifileError ('key seen without section!')
            if key is not None:
                chunk.data.set_one (key, data.strip ().decode ('utf8'))
            key = m.group (1)
            data = m.group (2)
            if not data[-1].isspace ():
                data += ' '
            chunk._addLine (fullline, key)
            continue

        if line[0].isspace () and key is not None:
            data += line.strip () + ' '
            chunk._addLine (fullline, key)
            continue

        raise InifileError ('unparsable line: ' + line[:-1])

    if chunk is not None:
        if key is not None:
            chunk.data.set_one (key, data.strip ().decode ('utf8'))
        yield chunk
        chunk.emit (outstream)
1025655
function flatten(trie, from) {
  from = from || []

  return _.reduce(trie, function (dict, subtrie, seg) {
    if (seg === '@') {
      return _.pair(from.join('/'), subtrie)
    }
    return _.concat(dict, flatten(subtrie, from.concat(seg)))
  })
}
1039667
def flatten_spec(spec, prefix,joiner=" :: "):
  """"""

  if any(filter(operator.methodcaller("startswith","Test"),spec.keys())):
    flat_spec = {}
    for (k,v) in spec.items():
      flat_spec.update(flatten_spec(v,prefix + joiner + k[5:]))
    return flat_spec 
  else:
    return {"Test "+prefix: spec}