On Wednesday 10 December 2008 10:40, Daniel Eklund wrote:
> Hi all,
>
> ...
>
> One thing I immediately ran up against were certain situations where
> I have a map and want to "modify" a value several levels deep into
> the hierarchy.  Imagine the following structure:
>
> (def nested-structure { :level 0,
>                            :nested1 { :level 1,
>                                      :nested2 { :level 2,
>                                                :final-data "initial data"}}})

Look into clojure.zip (.../src/clj/clojure/zip.clj in the Clojure 
source).


> ...
>
> 1) Am I missing something from the API that could have done what my
> function "path-rebind"? (I would have assumed that this would be a
> common need and that programmers would not need to roll their own
> each time)

Yes. The Zipper.


> 2) Am I missing out on a clever "reduce" usage that could have made
> this more in-line?  i.e. how's my code?
>
> It was after I made wrote this function and contemplated how I could
> make it abstract (i.e. with vectors, lists, etc) that I noticed the
> existence of the "zip" library...  Maybe question 1) above is
> answered by the "zip" library.  Is/Will the zip library be the
> recommended means by which to navigate/modify data structures of
> arbitrary depth, branching, and concrete 'type' ?

There you have it. I would say "yes."


> daniel


Randall Schulz

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to