Anonymous user
Same fringe: Difference between revisions
→{{header|Python}}: Fix adjustments of imports for Python 3.x as well as 2.x. Add-back needed fillvalue!
(→{{header|Python}}: Fix adjustments of imports for Python 3.x as well as 2.x. Add-back needed fillvalue!) |
|||
Line 39:
This example traverses each tree in step like in the Perl 6 example and will stop at the first miss-match without necessarily completing tree traversals and comparisons.
<lang python>try:
from itertools import zip_longest as izip_longest # Python 3.x
except:
▲ from itertools import izip_longest
def fringe(tree):
Line 56 ⟶ 53:
def samefringe(tree1, tree2):
return all(node1 == node2
for node1, node2 in
if __name__ == '__main__':
|