Effettivamente è molto compatta ed elegante, non conoscevo la funzione map(), 
praticamente è una forma più compatta di yield se non ho capito male .


grazie della dritta





Da: Dario Bertini
Data invio: ‎giovedì‎ ‎5‎ ‎dicembre‎ ‎2013 ‎00‎:‎54
A: Mailing List Python





>>> tree=((),((),((),((),(),((),)))),((),()))
>>> tree
((), ((), ((), ((), (), ((),)))), ((), ()))
>>> def height(tree):
...   if len(tree) == 0:
...     return 1
...   else:
...     return 1+max(map(height, tree))
...
>>> height(tree)
6


-- 
xmpp: berda...@gmail.com
bitmessage: BM-2cTYXfGiSTsnx3righ6aHcJSWe4MV17jDP
gpg fingerprint: 3F8D53518012716C4EEF7DF67B498306B3BF75A0 (used just
for signing commits)
_______________________________________________
Python mailing list
Python@lists.python.it
http://lists.python.it/mailman/listinfo/python
_______________________________________________
Python mailing list
Python@lists.python.it
http://lists.python.it/mailman/listinfo/python

Rispondere a