On May 28, 2:52 am, Korny Sietsma <[email protected]> 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 quickhash() != other.quickhash()
> return hash() != other.hash()
> end
>
> quickhash and hash store their results in instance variables so they
> only need to do the expensive calculations once - and quite often they
> never need to get calculated at all
I'm surprised no-one has yet mentioned force and delay:
(defn exact-match [a b]
(and (= (:size a) (:size b))
(= (force (:quickhash a)) (force (:quickhash b)))
(= (force (:hash a)) (force (:hash b)))))
- James
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---