Hi,

Am 04.03.2009 um 18:21 schrieb Dan:

How can I have my fitness computation be triggered on first access and reused afterward?

Maybe you can use a Delay.

  {:fitness (delay (compute-my-fitness))}

And when you access the value use force.

  (-> my-thing :fitness force)

The first time it is accessed, the value is calculated.
Afterwards the cached value is returned. If you don't
use the value of interim stages, it is not calculated.

Sincerely
Meikel

<commercial>
If you use maps as above I also have a lazy-map
package, which evaluates the value of key only
in case it is really accessed.

http://bitbucket.org/kotarak/lazymap
</commercial>

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to