It's not a secret anymore!*
The moose likes Clojure and the fly likes Recursive Grouping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Languages » Clojure
Bookmark "Recursive Grouping" Watch "Recursive Grouping" New topic
Author

Recursive Grouping

Ari King
Greenhorn

Joined: Apr 22, 2010
Posts: 20
The code below is supposed to group and nest values as key value pairs, while it does that it also encapsulates the pairs in lists; does anyone know why? See below for code and example (notice the embolden parentheses):

({"a" ({"dan" [["a" 2011 "dan"] ["a" 2010 "dan"]]})} {"b" ({"jon" [["b" 2011 "jon"]]})})

Ari King
Greenhorn

Joined: Apr 22, 2010
Posts: 20
Ari King wrote:The code below is supposed to group and nest values as key value pairs, while it does that it also encapsulates the pairs in lists; does anyone know why? See below for code and example (notice the embolden parentheses):

({"a" ({"dan" [["a" 2011 "dan"] ["a" 2010 "dan"]]})} {"b" ({"jon" [["b" 2011 "jon"]]})})


I figured it out, I had to add "into {} ...". From what I understand, I had to do this because "for" returns a lazy sequence hence the parentheses; thus I need to transform the sequence into a map.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Recursive Grouping
 
Similar Threads
need help about generics
Set & List interface extend Collection, so Why doesn't Map interface extend Collection?
How to Collapse Nested Map into a Sequence of Flat Maps
Extracting and Comparing Data
Files from a directory is not being recognized