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
class Trough < Array | |
alias_method :|, :push | |
def call(context) | |
reduce(context) do |ctx, pig| | |
pig.new(ctx).call | |
ctx | |
end | |
end | |
end |
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 merge-sorted [comparator & xss] | |
(let [xss (into-array Object (remove empty? xss)) | |
pq (java.util.PriorityQueue. | |
(count xss) #(comparator (val %1) (val %2)))] | |
(dotimes [i (count xss)] | |
(let [xs (aget xss i)] | |
(.add pq (pair i (first xs))) | |
(aset xss i (next xs)))) | |
((fn go [] | |
(lazy-seq |