As mentioned before, most file systems have the ability of providing
callback to changes in files/directories, at SE 6 using this ability
requires resorting to native code (JNA or JNI, see
http://jnotify.sourceforge.net/)
, in SE 7 this will be implemented in NIO 2 (http://java.sun.com/
For whatever reason I just can't seem to put this problem down.
I have rewritten the code substantially. A major bottleneck was using
Java's MD5 classes. The Fast MD5 library really is, and that helped
a lot. I did get the - notation to work and I have a reasonable HOF
now for doing the
I keep reading this thread when I should be going to bed :) Sadly,
this stuff is in what I call my 0.2% time so I'm not working very
hard on it right now.
The ruby code, which basically works (but is rather ugly in parts)
relies on reading the whole file tree into memory, and then traversing
On Thu, May 28, 2009 at 7:58 AM, Daniel Lyons fus...@storytotell.org wrote:
On May 27, 2009, at 11:51 PM, Timothy Pratley wrote:
I wonder if there is a more idiomatic way to compare two lazy
sequences... lazily?
I came up with (some (complement zero?) (map compare list-1 list-2))
in my
I wonder if there is a more idiomatic way to compare two lazy
sequences... lazily?
You can just use =.
(= seq1 seq2)
It works lazily.
user (= (iterate inc 0) (map #(do (println %) %) [0 1 2 -3 4 5 6]) )
0
1
2
-3
false
How sweet!
2009/5/28 Daniel Lyons fus...@storytotell.org:
On May
On May 28, 2009, at 12:35 AM, Mikio Hokari wrote:
I wonder if there is a more idiomatic way to compare two lazy
sequences... lazily?
You can just use =.
(= seq1 seq2)
It works lazily.
user (= (iterate inc 0) (map #(do (println %) %) [0 1 2 -3 4 5 6]) )
0
1
2
-3
false
Seems odd
On May 28, 2009, at 12:35 AM, Mikio Hokari wrote:
I wonder if there is a more idiomatic way to compare two lazy
sequences... lazily?
You can just use =.
I guess I'm imagining a group-by like Haskell's, which takes an
equality comparison function and just returns a list of lists. Which
I have uploaded my solution to the Google group. It seems to work well
for small directories but runs out of memory pretty quickly on a huge
directory. I'd appreciate any help with making it more efficient or
prettier. I'm sure I can drum up my own uses for this.
Also, I thought I could
Thanks for the tip about lazy = Mikio!
Wow Daniel, a very thorough description there - it seems file systems
are close to your heart :) I've taken your design and implemented a
variant on it:
http://groups.google.com/group/clojure/web/find-duplicates.clj
For this sort of domain I think
Hahaha - you beat me to it!
I expect the memory usage would be dominated by the slurping (if there
are large files), perhaps using a DigestInputStream avoids this? (I'm
not familiar with it, but sounds... streamy). PS: you defined file-
comparator but don't use it, your source could be even
Ah, sorry, I get it now - very cute! This is just the sort of thing I
need to understand better - hard to break out of years of
object-oriented thinking.
- Korny
On Thu, May 28, 2009 at 2:34 PM, Mikio Hokari mikiohok...@gmail.com wrote:
Hash calculation runs only when necessary, because
Cool stuff - I really should go to bed now, but I'll look at this
further in the morning.
By the way, in response to whoever suggested pre-sorting files; I
sort-of do this (in the old ruby version) but actually, mostly the
program is looking for duplicate *directories* of files - the goal is
to
On May 28, 2:52 am, Korny Sietsma ko...@sietsma.com wrote:
Basically, I have a FileInfo class that wraps a data file, used to
compare lots of files on my system.
It has an exact_match method similar to:
def exact_match(other)
return false if size != other.size
return false if
Hi all,
I have some ruby code that I'm thinking of porting to clojure, but I'm
not sure how to translate this idiom to a functional world:
I have objects that are externally immutable, but have internal
mutable state they use for optimisation, specifically in this case to
defer un-needed
Hello.
I am new to clojure, but try it.
code:
(defn get-size [filename]
(println 'size filename)
(count filename))
(defn get-quickhash [filename]
(println 'quickhash filename)
(hash (take 3 filename)))
(defn get-hash [filename]
(println 'hash
Trouble here is, I only want to call the hash functions as needed.
This is doing file differencing, and if I only have a single file of
(say) 200 megabytes, I never need to calculate it's hash, as I'll
never actually compare it to another file of exactly the same size.
- Korny
On Thu, May 28,
Sounds like a job for lazy-map to me!
http://kotka.de/projects/clojure/lazy-map.html
On May 28, 11:52 am, Korny Sietsma ko...@sietsma.com wrote:
Hi all,
I have some ruby code that I'm thinking of porting to clojure, but I'm
not sure how to translate this idiom to a functional world:
I have
Hash calculation runs only when necessary, because
Clojure's map function is lazy now.
more sample code:
(nth (get-info a.txt) 0)
(nth (get-info b.txt) 0)
(nth (get-info b.txt) 1)
result:
size a.txt
size b.txt
quickhash b.txt
Output result shows it.
When
(nth (get-info a.txt) 0)
is
Yes that is a very elegant solution.
For convenience you might want another function:
(defn fast-compare
Given two filenames returns true if the files are identical
[fn1 fn2]
(let [i1 (get-info fn1), i2 (get-info fn2)]
(and (= (first i1) (first i2))
(= (second i1) (second i2))
On May 27, 2009, at 7:52 PM, Korny Sietsma wrote:
How would I do this in a functional way? My first effort would be
something like
(defn hash [filename] (memoize (... hash function ...)))
but I have a couple of problems with this:
- it doesn't seem to store the hash value with the rest
On May 27, 2009, at 11:51 PM, Timothy Pratley wrote:
I wonder if there is a more idiomatic way to compare two lazy
sequences... lazily?
I came up with (some (complement zero?) (map compare list-1 list-2))
in my response which missed yours by seconds. :) I'm not sure it's
great but it does
21 matches
Mail list logo