Skip to content

Instantly share code, notes, and snippets.

@theirix
Created June 7, 2012 18:43
Show Gist options
  • Save theirix/2890701 to your computer and use it in GitHub Desktop.
Save theirix/2890701 to your computer and use it in GitHub Desktop.
buckets
# breaks array to buckets delimited by a specified item
def buckets array, &block
buckets = []
while true
cur = array.find_index &block
buckets << array unless cur
break unless cur
buckets << array[0...cur] if cur > 0
array = array.drop(cur+1)
end
buckets
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment