Skip to content

Instantly share code, notes, and snippets.

@beaumartinez
Created September 13, 2012 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beaumartinez/3715936 to your computer and use it in GitHub Desktop.
Save beaumartinez/3715936 to your computer and use it in GitHub Desktop.
def split_at_predicate(predicate, sequence):
split_sequence = list()
for item in sequence:
if predicate(item):
yield split_sequence
split_sequence = list()
split_sequence.append(item)
yield split_sequence
@sjl
Copy link

sjl commented Sep 13, 2012

Breaks on [] but otherwise yeah.

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