recursive map on nested list

johnzenger at gmail.com johnzenger at gmail.com
Tue Mar 21 10:48:25 EST 2006


Uglier than yours, but down to two lines:

def recur_map(f, data):
	return [ not hasattr(x, "__iter__") and f(x) or recur_map(f, x) for x
in data ]




More information about the Python-list mailing list