Created
September 12, 2022 07:07
-
-
Save curegit/2f83e0b8fd820f110f759d20c1a79d34 to your computer and use it in GitHub Desktop.
リストをずらしたイテレーターを返す
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def shifted(list, shift=0): | |
n = len(list) | |
for i in range(shift % n, n): | |
yield list[i] | |
for i in range(0, shift % n): | |
yield list[i] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment