This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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. |