Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You said "map" but are talking about "tree". There are other ways maps can compose, e.g. graph, which do not lead to deep nesting and transformations.


> You said "map" but are talking about "tree".

In essence yes, the maps I see being bandied about in clj tend to have tree structures.

Haven't seen much/any use of graphs in clj code. Deep nesting has become almost idiomatic at this point from my POV.

Could you provide example/pointer to clj code using a graph in lieu or in addition to a map?


A tree is a type of graph. Also, if your graph has cycles you could end up with infinite levels of nesting. Trees are simpler by definition.


I think that the distinction that dustingetz was trying to make is related to the fact that trees are graphs. Many applications naively nest data in tree structures with links from nodes to other nodes that are implied by the data. Maps are powerful enough to represent arbitrary graphs, so if you don't take advantage of this you end up with a lot of duplicated data in tree format. Then you need to do a bunch of tree traversals to link the data to itself at query time.


graphs are more general! we could argue which is simpler. Graphs store data in normal form. Trees are denormalized.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: