• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Recursive Grouping

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.

 
No one can make you feel inferior without your consent - Eleanor Roosevelt. tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic