MCPcopy Create free account
hub / github.com/ActiveState/code / tails

Function tails

recipes/Python/577574_PythInfinite_Rotations/recipe-577574.py:29–34  ·  view source on GitHub ↗

tails([1,2,3,4,5]) --> [[1,2,3,4,5], [2,3,4,5], [3,4,5], [4,5], [5], []]

(it)

Source from the content-addressed store, hash-verified

27# use memory only propertional to the offset difference between the generated
28# iterators.
29def tails(it):
30 """ tails([1,2,3,4,5]) --> [[1,2,3,4,5], [2,3,4,5], [3,4,5], [4,5], [5], []] """
31 while True:
32 tail, it = tee(it)
33 yield tail
34 next(it)
35
36# We can now define two new rotations functions.
37# The first one is very similar to the above, but since we never keep all list

Callers 1

rotationsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected