This is my take on this: http://gist.github.com/957028
The second file produces the correct result. The result isn't exactly like
you asked for. This is because it wouldn't support files that isn't in the
lowest level.
Ex:
(restore-hierarchy [["top" "level" "file1"] ["top" "level" "file2"] ["top"
"level2" "file3"]])
=> {"top" {"level" {:files ("file1" "file2")}, "level2" {:files ("file3")}}}
(restore-hierarchy [["top" "file"] ["top" "level" "file1"]])
=> {"top" {"level" {:files ("file1")}, :files ("file")}}
Note the last :files in the "top" level.
Jonathan
On Thu, May 5, 2011 at 2:40 PM, Steffen <[email protected]> wrote:
> Hello,
>
> I'm trying to come up with a way to recreate a directory hierarchy. Entries
> within zip archives are just flat strings like "top/level/file1", but I
> would like to operate on them hierarchically. So my problem could be stated
> as:
> If
>
> (restore-hierarchy [["top" "level" "file1"] ["top" "level" "file2"]
> ["top" "level2" "file3"]])
>
> returns
>
> {"top" {"level" ("file1" "file2"), "level2" ("file3")}}
>
> what does a nice definition of #'restore-hierarchy look like? Sadly my own
> attempts to hack it are too embarrassing to post them here...
>
> Thanks,
>
> Steffen
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with
> your first post.
> 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
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
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