On Apr 10, 3:54 pm, Jason Wolfe <jawo...@berkeley.edu> wrote: > In case this helps, my use case is as follows. I'm working on search > algorithms that manage maps from keys representing reachable states to > values representing the cost of reaching those states. When I union > two such maps, I retain the minimum value (cost) for each key (state), > associng in the new key and its (lower) cost. Now, states have > metadata describing the path taken to reach them. I think this is a > proper use of metadata, since two states reached by different paths > should be considered equal. Then, after unioning some maps, I'd like > to be able to retrieve the best path associated with a state by just > reading the metadata off the key. > > The only alternative I can see would be to store the path with the > cost in a second map, but this ends up being considerably less > elegant. Any other ideas/suggestions? Does this seem like a perverse > use of metadata to you?
Not necessarily perverse, but perhaps a little twisted. :) I'd probably do it using two maps, or one map with composite values like {:path ..., :cost ...}. Or... the cost will be entirely dependent on the path, right? So make cost a function, memoize it, and you only need to store the paths. -Stuart Sierra --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---