Created
October 3, 2010 20:33
-
-
Save acardona/608905 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
; find-all-to-all returns a lazy list of lists of object instances | |
; and we want a map of instance vs. number of appearances | |
; This one blows up RAM: | |
(apply merge-with + | |
(map #(zipmap % (repeat 1)) | |
(find-all-to-all-paths nodes degrees))) | |
; This one doesn't: | |
(reduce | |
#(reduce | |
(fn [m ^Node nd] (assoc m nd (inc (get m nd 0)))) | |
%1 ; a map | |
%2) ; a vector of nodes | |
{} | |
(find-all-to-all-paths nodes degrees)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment