On Thu, May 05, 2011 at 05:40:02AM -0700, Steffen 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
Am Donnerstag, 5. Mai 2011 16:06:52 UTC+2 schrieb odyssomay:
>
> 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.
Your
Beautiful solution, I got a lot out of it.
Thanks Juha!
--
Ambrose
On Thu, May 5, 2011 at 10:08 PM, Juha Arpiainen wrote:
> (defn add-path [h path]
> (let [dir (butlast path)
>entry (last path)]
>(update-in h dir (fn [x] (if x (conj x entry) [entry])
>
> (defn restore-hierarchy
(defn add-path [h path]
(let [dir (butlast path)
entry (last path)]
(update-in h dir (fn [x] (if x (conj x entry) [entry])
(defn restore-hierarchy [paths]
(reduce add-path {} paths))
Then
(restore-hierarchy [["top" "level" "file1"] ["top" "level" "file2"]
["top" "level2" "fil
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"
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" "l