Skip to content

Commit

Permalink
feat: add shuffle
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveitaly committed Jan 29, 2024
1 parent 485e526 commit 3fc9bd8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion funcy/seqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


__all__ = [
'count', 'cycle', 'repeat', 'repeatedly', 'iterate',
'count', 'cycle', 'repeat', 'repeatedly', 'iterate', 'shuffle',
'take', 'drop', 'first', 'second', 'nth', 'last', 'rest', 'butlast', 'ilen',
'map', 'filter', 'lmap', 'lfilter', 'remove', 'lremove', 'keep', 'lkeep', 'without', 'lwithout',
'concat', 'lconcat', 'chain', 'cat', 'lcat', 'flatten', 'lflatten', 'mapcat', 'lmapcat',
Expand All @@ -34,6 +34,12 @@ def _lfilter(f, seq):

# Re-export
from itertools import count, cycle, repeat
import random

def shuffle(seq):
new_seq = seq.copy()
random.shuffle(new_seq)
return new_seq

def repeatedly(f, n=EMPTY):
"""Takes a function of no args, presumably with side effects,
Expand Down

0 comments on commit 3fc9bd8

Please sign in to comment.