take(f) a list of keys and fill in others with val
489900
def takef(d,l,val=None):
    ''''''
    return {i:(d[i] if i in d else val)
            for i in l};
1299248
function (keyOrList, func) {
				var keys = toArray(keyOrList), i = -1, len = keys.length, key;
				while (++i < len) {
					key = keys[i];
					func(key, me.get(key));
				}
				return me;
			}
572785
def dict_take(dict_, keys, *d):
    
    try:
        return list(dict_take_gen(dict_, keys, *d))
    except TypeError:
        return list(dict_take_gen(dict_, keys, *d))[0]
896779
function fnInvertKeyValues( aIn )
{
	var aRet=[];
	for ( var i=0, iLen=aIn.length ; i<iLen ; i++ )
	{
		aRet[ aIn[i] ] = i;
	}
	return aRet;
}
130257
function fv(vals, key) {
  if (!vals) return;
  vals.forEach(function(v) {
    if (v.key === key && vals[key] !== 'Not available') {
      return vals[key];
    }
  });
}
871860
def append(self, key, val, time=0, min_compress_len=0):
        '''
        '''
        return self._set("append", key, val, time, min_compress_len)
1028450
def flat_list(input_list):
    

    """
    x = input_list
    if isinstance(x, list):
        return [a for i in x for a in flat_list(i)]
    else:
        return [x]
218444
function addKeyToList(list, key, object) {
    for (var i = list.length - 1; i >= 0; i--) {
        if (list[i][key] == object[key]) {
            return false;
        }
    }
    list.push(object);
    return true;
}
344261
def _dict_set(self, key, val):
        '''
        
        '''
        if key != None and self.stringify_keys:
            key = str(key)
        db = self._keyed_db[self.split_func(key)]
        db._dict_set(key, val)
622914
def collate(*iterables, **kwargs):
    
    key = kwargs.pop('key', lambda a: a)
    reverse = kwargs.pop('reverse', False)
    min_or_max = max if reverse else min

    rows = [iter(iterable) for iterable in iterables if iterable]
    next_values = {}
    by_key = []

    def gather_next_value(row, index):
        try:
            next_value = next(row)
        except StopIteration:
            pass
        else:
            next_values[index] = next_value
            by_key.append((key(next_value), index))

    for index, row in enumerate(rows):
        gather_next_value(row, index)

    while by_key:
        key_value, index = min_or_max(by_key)
        by_key.remove((key_value, index))
        next_value = next_values.pop(index)
        yield next_value
        gather_next_value(rows[index], index)
940192
public ValueMap withList(String key, List<?> val) {
        super.put(key, val == null ? null : new ArrayList<Object>(val));
        return this;
    }
385046
def _keys_via_value_nonrecur(d,v):
    '''
        
    '''
    rslt = []
    for key in d:
        if(d[key] == v):
            rslt.append(key)
    return(rslt)
267085
def mget(self, keys, *args):
        
        keys = [self.redis_key(k) for k in self._parse_values(keys, args)]
        with self.pipe as pipe:
            f = Future()
            res = pipe.mget(keys)

            def cb():
                decode = self.valueparse.decode
                f.set([None if r is None else decode(r) for r in res.result])

            pipe.on_execute(cb)
            return f
1278337
private void swapVals(int e, int f, int[] vals) {
        int vals_e = vals[e];
        vals[e] = vals[f];
        vals[f] = vals_e;
    }
93336
def key_assoc_val(d, func, exclude=None):
    
    vs = list(d.values())
    ks = list(d.keys())
    key = ks[vs.index(func(vs))]
    return key
496693
def _nest_vars_in_rec(var_items, rec_items, input_order, items_by_key, parallel):
    
    num_items = var_items
    var_items = list(var_items)[0]
    if rec_items:
        rec_items = list(rec_items)[0]
        if ((rec_items == 1 and var_items > 1) or parallel.startswith("batch")):
            num_items = set([rec_items])
            for var_key in (k for (k, t) in input_order.items() if t != "record"):
                var_key = tuple(var_key.split("__"))
                items_by_key[var_key] = [items_by_key[var_key]] * rec_items
        else:
            assert var_items == rec_items, (var_items, rec_items)
    return items_by_key, num_items
386997
def argmin(input_, key=None):
    
    # if isinstance(input_, dict):
    #     return list(input_.keys())[argmin(list(input_.values()))]
    # elif hasattr(input_, 'index'):
    #     return input_.index(min(input_))
    # else:
    #     return min(enumerate(input_), key=operator.itemgetter(1))[0]
    if isinstance(input, dict):
        return list(input.keys())[argmin(list(input.values()), key=key)]
    else:
        if key is None:
            def _key(item):
                return item[1]
        else:
            def _key(item):
                return key(item[1])
        return min(enumerate(input), key=_key)[0]