5 ms·
Thanks for this. I didn't know about update-in. Are there other 'update' functions? However, it's a good thing you want a DAG, because with immutable data st
by herdrick 16y ago
Thanks for this. I didn't know about update-in. Are there other 'update' functions?
However, it's a good thing you want a DAG, because with immutable data structures you're hosed if you want a cyclic graph. Or at least you won't be building them out of such structures, which means you aren't getting to use Clojure's functions for sequences, collections and maps. Thus Clojure does not seem to be a good tool for graphs.
- arohner 16y agoActually, when I said 'update', I meant the functions that in standard languages that would modify the existing structure return a new one, but it's great you found update-in. That's a beautiful function. There's also assoc-in, which is basically just a more specialized assoc-in. I've built cyclical graphs in Clojure. The simplest form looks like {:nodes #{:a :b :c} :edges {:a #{:b} :b #{:c} :c #{:a}}} (for non-clojurians, {} is a map, and #{} is a set)