Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the traversal of iterable objects in big data

Shulou Source: shulou.com Published: 2022-06-02 03:37:48 10月03日 Update

This article introduces what is the traversal of iterable objects in big data. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.

Items = [1, 2, 3, 4, 4, 5, and 6] results: 1 [2, 3, 3, 4, 4, 5, 5, 6] 2 [3, 4, 5, 5, 6] 3 [4, 5, 5, 6] 6 []

Method 1:

Def sum (items): # Recursive head,*tail = items print (head,tail) return head + sum (tail) if tail else head

Method 2:

Def sum (items): # unpack tail = items while tail: head,*tail = tail print (head,tail)

Method 3:

Def sum (items): # slice tail = items while tail: print (tail [: 1] [0], tail [1:]) tail = tail [1:]

Method 4:

Items = [1 list 2, items 3] def sum (items): # list method while items: print (items [0], items [1:]) items.pop (0) this is the end of the traversal of iterable objects in big data. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Methods objects data iterations content more help good interest guys buddies articles knowledge articles results recursion references Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple MySQL Xiaomi OPPO Reno macOS