Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

treemap

>>> def treemap(lst):
...     for i in range(len(lst)):
...         if type(lst[i])==int:
...             lst[i]=lst[i]**2
...         elif type(lst[i])==list:
...             treemap(lst[i])
...     return lst
>>> lst = [1, 2, 3, [4, [5, 6], 7]]
>>> print(treemap(lst))
[1, 4, 9, [16, [25, 36], 49]]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #treemap
ADD COMMENT
Topic
Name
5+4 =