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 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 clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to