Skip to content

Instantly share code, notes, and snippets.

View mccraigmccraig's full-sized avatar

mccraigmccraig of the clan mccraig mccraigmccraig

View GitHub Profile
@mccraigmccraig
mccraigmccraig / common_followers
Created July 3, 2009 12:23 — forked from DRMacIver/common_followers
ruby : find twitter common followers
#!/usr/bin/env ruby
# Trivial little twitter script
# Pass it a list of names as command line arguments
# and it will return a list of all people who follow everyone in the
# list.
# A person is implicitly assumed to follow themselves, so if foo follows
# bar and bar follows foo then common_followers foo bar would include
# both foo and bar in the output, but if bar did not follow foo it
# would include neither.
(defn multi-split-with
"Returns a lazy collection of lists which elements ..."
[pred coll]
(let [[head tail] (split-with pred coll)
tail-without-seps (drop-while (complement pred) tail)]
(lazy-seq
(if (seq tail-without-seps)
(cons head (multi-split-with pred tail-without-seps))
(list head)))))