Skip to content

Instantly share code, notes, and snippets.

@curegit
Created September 12, 2022 07:07
Show Gist options
  • Save curegit/2f83e0b8fd820f110f759d20c1a79d34 to your computer and use it in GitHub Desktop.
Save curegit/2f83e0b8fd820f110f759d20c1a79d34 to your computer and use it in GitHub Desktop.
リストをずらしたイテレーターを返す
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