Skip to content

Instantly share code, notes, and snippets.

@losingkeys
Created November 20, 2012 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save losingkeys/4118756 to your computer and use it in GitHub Desktop.
Save losingkeys/4118756 to your computer and use it in GitHub Desktop.
(def playlist
[{:title "Elephant", :artist "The White Stripes", :year 2003}
{:title "Helioself", :artist "Papas Fritas", :year 1997}
{:title "Stories from the City, Stories from the Sea",
:artist "PJ Harvey", :year 2000}
{:title "Buildings and Grounds", :artist "Papas Fritas", :year 2000}
{:title "Zen Rodeo", :artist "Mardi Gras BB", :year 2002}])
; (group-by :artist playlist) returns:
;= {"Papas Fritas" [{:title "Helioself", :artist "Papas Fritas", :year 1997}
;= {:title "Buildings and Grounds", :artist "Papas Fritas"}]
;= ...}
; desired:
;= {"Papas Fritas" [{:title "Helioself", :year 1997}
;= {:title "Buildings and Grounds"}]
;= ...}
; from http://www.clojurebook.com/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment