now I'm confused, which one is the right memoize to use?
and is that true about dosync? "the nesting property of dosync: a nested
transaction merges with the surrounding one." or did it change in the past
almost 3 years since?


On Wed, Jan 23, 2013 at 12:08 PM, David Powell <djpow...@djpowell.net>wrote:

>
> Specifically, core.memoize uses core.cache to provide more flexible
> replacements for memoize:
> https://github.com/clojure/core.memoize
>
> --
> Dave
>
>
>
> On Wed, Jan 23, 2013 at 8:12 AM, Baishampayan Ghose <b.gh...@gmail.com>wrote:
>
>> Take a look at core.cache - https://github.com/clojure/core.cache ~BG
>>
>> On Wed, Jan 23, 2013 at 1:11 PM, Omer Iqbal <momeriqb...@gmail.com>
>> wrote:
>> > I've been reading a bit about the STM, and here's an implementation of a
>> > FIFO cache for producing a memoized version of a function. Is it
>> correct to
>> > use the STM in this case, or are there any  drawbacks?
>> >
>> > (defn bounded-memoize
>> >   "Return a bounded memoized version of fn 'f'
>> >    that caches the last 'k' computed values"
>> >   [f k]
>> >   (let [cache (ref {})
>> >         values (ref clojure.lang.PersistentQueue/EMPTY)]
>> >     (fn [& args]
>> >       (if-let [e (find @cache args)]
>> >         (val e)
>> >         (let [result (apply f args)]
>> >           (dosync
>> >            (alter values conj args)
>> >            (alter cache assoc args result)
>> >            (if (> (count @values) k)
>> >              (let [evict (peek @values)]
>> >                (alter values pop)
>> >                (alter cache dissoc evict))
>> >              )
>> >            result
>> >            ))
>> >
>> >         )
>> >       ))
>> >   )
>> >
>> >
>> > --
>> > --
>> > 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
>> > Note that posts from new members are moderated - please be patient with
>> your
>> > first post.
>> > 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
>> >
>> >
>>
>>
>>
>> --
>> Baishampayan Ghose
>> b.ghose at gmail.com
>>
>> --
>> --
>> 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
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> 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
>>
>>
>>
>  --
> --
> 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
> Note that posts from new members are moderated - please be patient with
> your first post.
> 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
>
>
>



-- 
I may be wrong or incomplete.
Please express any corrections / additions,
they are encouraged and appreciated.
At least one entity is bound to be transformed if you do ;)

-- 
-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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