Skip to content

feat: add shuffle#147

Open
iloveitaly wants to merge 2 commits intoSuor:masterfrom
iloveitaly:add-shuffle
Open

feat: add shuffle#147
iloveitaly wants to merge 2 commits intoSuor:masterfrom
iloveitaly:add-shuffle

Conversation

@iloveitaly
Copy link
Contributor

No description provided.

@Suor
Copy link
Owner

Suor commented Jan 30, 2024

This makes sense, I would call it shuffled() though akin sorted built-in and to not be confused with random.shuffle(). Also, I would use list(seq) instead of seq.copy() to make it work with arbitrary sequences.

@iloveitaly
Copy link
Contributor Author

I've updated the PR based on your feedback:

  • Renamed shuffle to shuffled to follow Python's naming conventions (like sorted).
  • Updated the implementation to use list(seq) instead of seq.copy(), which now correctly handles arbitrary sequences like iterators and ranges.
  • Added a docstring to shuffled and updated the documentation in docs/seqs.rst and docs/cheatsheet.rst.
  • Verified all tests pass, including a new test case for shuffled with range.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments