root/lib/collection.py @ 1882
1 |
# Data structures
|
---|---|
2 |
|
3 |
import iters |
4 |
|
5 |
def rmap(func, value): |
6 |
'''Recursively applies func to all members of value'''
|
7 |
rmap_ = lambda v: rmap(func, v) |
8 |
if isinstance(value, dict): |
9 |
return dict(((k, rmap_(v)) for k, v in value.iteritems())) |
10 |
elif iters.is_iterable(value): return map(rmap_, value) |
11 |
else: return func(value) |