Map a function f:{primitive} -> B to a dictionary.
776625
def dict_map(f, primitive, dic):
    """"""

    if primitive(dic):
        return f(dic)
    if isinstance(dic, Mapping):
        return {dict_map(f, primitive, key): dict_map(f, primitive, value)
                for key, value in dic.items()}
    if isinstance(dic, str):
        return dic
    if isinstance(dic, Sequence):
        return [dict_map(f, primitive, value) for value in dic]
    return dic
1371124
def map(self, fn: Callable[[Any], Any]) -> 'Reader':
        
        """
        def _compose(x: Any) -> Any:
            try:
                ret = fn(self.run(x))
            except TypeError:
                ret = partial(fn, self.run(x))
            return ret
        return Reader(_compose)
689067
def map_collection(func, collection):
    
    datatype = type(collection)
    if isinstance(collection, Mapping):
        return datatype((key, func(val)) for key, val in collection.items())
    if is_string(collection):
        return collection
    elif isinstance(collection, Iterable):
        return datatype(map(func, collection))
    else:
        return collection
976846
def nested_map(x, f):
  """"""
  if isinstance(x, list):
    return [nested_map(y, f) for y in x]
  if isinstance(x, tuple):
    return tuple([nested_map(y, f) for y in x])
  if isinstance(x, dict):
    return {k: nested_map(x[k], f) for k in x}
  return f(x)
1043639
def __rmath(self, f, x):
        

        d = {}
        if isinstance(x, (int, long, float, complex)):
            for i in self.__d: d[i] = f(x , self.__d[i])
        else: raise ValueError('Cannot execute reverse operator, only (int, float, complex) as first operand possible')

        return d
419526
def dict_mirror(d,**kwargs):
    '''
        
    '''
    md = {}
    if('sort_func' in kwargs):
        sort_func = kwargs['sort_func']
    else:
        sort_func = sorted
    vl = list(d.values())
    uvl = elel.uniqualize(vl)
    for v in uvl:
        kl = _keys_via_value_nonrecur(d,v)
        k = sorted(kl)[0]
        md[v] = k
    return(md)
1294438
def to_dict(self, get_value=None):
        """"""
        self.trim()
        result = {}
        for key, value in iteritems(self.counters):
            if get_value is not None:
                value = getattr(value, get_value)
            r = result
            for _key in key[:-1]:
                r = r.setdefault(_key, {})
            r[key[-1]] = value
        return result
1352482
def dict_factory(cursor, row):
    """"""
    d = {}
    for idx, col in enumerate(cursor.description):
        d[col[0]] = row[idx]
    return d
564092
def memoize(fn):
    """"""
    memo = {}

    @wraps(fn)
    def wrapper(*args, **kwargs):
        if not memoize.disabled:
            key = pickle.dumps((args, kwargs))
            if key not in memo:
                memo[key] = fn(*args, **kwargs)
            value = memo[key]
        else:
            # Memoize is disabled, call the function
            value = fn(*args, **kwargs)

        return value

    return wrapper
173541
def invert_dict(invertible_dict):
    """"""
    inverted = {}
    for k, v in six.iteritems(invertible_dict):
        if not isinstance(v, Hashable):
            raise TypeError(u'Expected an invertible dict, but value at key {} has type {}'.format(
                k, type(v).__name__))
        if v in inverted:
            raise TypeError(u'Expected an invertible dict, but keys '
                            u'{} and {} map to the same value'.format(
                                inverted[v], k))
        inverted[v] = k
    return inverted
717229
def c_func(funcname, reverse=False, nans=False, scalar=False):
    
    varnames = ['group_idx', 'a', 'ret', 'counter']
    codebase = c_base_reverse if reverse else c_base
    iteration = c_iter_scalar[funcname] if scalar else c_iter[funcname]
    if scalar:
        varnames.remove('a')
    return codebase % dict(init=c_init(varnames), iter=iteration,
                           finish=c_finish.get(funcname, ''),
                           ri_redir=(c_ri_redir if nans else c_ri))
1348104
def scalar_input_map(func, input_):
    
    if util_iter.isiterable(input_):
        return list(map(func, input_))
    else:
        return func(input_)
794332
def _(f, x):
    
    result = {}
    for k, v in x.items():
        k_, v_ = f(k, v)
        result[k_] = v_
    return result
405847
def recursive_asdict(d):
    """"""
    out = {}
    for k, v in asdict(d).iteritems():
        if hasattr(v, '__keylist__'):
            out[k] = recursive_asdict(v)
        elif isinstance(v, list):
            out[k] = []
            for item in v:
                if hasattr(item, '__keylist__'):
                    out[k].append(recursive_asdict(item))
                else:
                    out[k].append(item)
        else:
            out[k] = v
    return out
426140
function map(f, a) {

  var b =  new Array({});
  for (var i = 0; i < a.length; i++) {
    b[i] = f(typeof a[i] === "string"? a[i]: JSON.stringify(a[i]));
    // JSON.stringnify
    // b[i] = f(a[i]);
  }
  return b;
}
282146
def _get_keys_defdict(self):
        '''
        '''
        # inspect argspecs
        argspec = inspect.getargspec(self.func)
        keys, defvals = argspec.args, argspec.defaults

        # convert to (list_of_argkeys, dict_of_default_keys)
        if defvals is None:
            return keys, None
        else:
            defvals = list(defvals)
            keys.reverse()
            defvals.reverse()
            defdict = dict(zip(keys, defvals))
            keys.reverse()
            return keys, defdict
1143790
function mapToObject(input, mapFunc) {
    const obj = {};
    for (const element of input) {
        obj[element] = mapFunc(element);
    }
    return obj;
}