nicer than my loop. I have to get used to avoiding loops when i can,
On 15 Dez., 22:18, Laurent PETIT <
laurent.pe...@gmail.com> wrote:
> Hello,
>
> so you have a mutating object. To mutate it you must call a method (please
> note, I don't use the term function, which has a different meaning than a
> class method, especially in clojure where functions are first class).
>
> You want a final call something like that:
> (mystery-fn-or-macro object method-to-call list-of-items)
>
> If you can afford in your situation of passing a real higher order function
> to mystery-fn-or-macro , like (fn [obj item] (.method-to-call obj item)),
> then mystery-fn-or-macro is simply based on doseq :
>
> (defn mystery-fn [object fn-calling-method list-of-items]
> (doseq [item list-of-items] (fn-calling-method obj item)))
>
> and you call it as such :
> (mystery-fn object (fn [obj item] (.method-to-call obj item)) list-of-items)
>
> There's also the memfn macro in clojure.core for exactly this purpose:
> (mystery-fn object (memfn method-to-call item) list-of-items)
>
> But note that those days, memfn is somewhat deprecated in favor of raw (fn
> ...) or #(...) constructs.
>
> HTH,
>
> --
> Laurent
>