On Mar 8, 2010, at 11:20 PM, Michał Marczyk wrote:
> It's simple to write this way... And if you provide type hints, I'd
> expect the resulting function to be quite performant. If you don't
> care about that, here's a flexible alternative using eval:
>
> user> (defmacro methodfn [name]
>`
On Mar 8, 2010, at 1:06 PM, Nurullah Akkaya wrote:
> Using this,
>
> http://paste.lisp.org/display/67182
>
> would allow you to do,
>
> (let [config {:str "fred" :beg 2 :end 3}]
> (apply (jfn 'substring) (map config [:str :beg :end])))
That's quite nice. Thanks!
--
You received this message
On 8 March 2010 17:37, Michael Gardner wrote:
> Thanks for the tip. After some experimentation:
>
> (apply (memfn connect a b c d) store (map config [:host :port :user
> :password]))
Oh right, you wanted more arguments. So I should have suggested
#(.connect %1 %2 %3 %4).
> but why does memfn re
On Mar 8, 2010, at 9:16 AM, Adrian Cuthbertson wrote:
> Maybe just;
> (let [{:keys host port user password} config]
> (.connect store host port user password))
Having to repeat the variable names rather defeats the purpose, since this
version is longer than the original and still feels redunda
On Mar 8, 2010, at 6:50 AM, Volkan YAZICI wrote:
> See memfn in Clojure API docs.
Thanks for the tip. After some experimentation:
(apply (memfn connect a b c d) store (map config [:host :port :user :password]))
but why does memfn require these "dummy" arguments?
--
You received this message b
I find #(.connect %) to be the most pleasing form.
Sincerely,
Michał
--
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
On Mon, Mar 8, 2010 at 9:47 AM, Michael Gardner wrote:
> Given a Java instance 'store' with a .connect method that takes a host, port,
> user and password, and given a hash-map 'config' with corresponding keyword
> values, I wanted to do something like:
>
> (apply .connect store (map config [:ho
There's a fundamental law of nature that says; if you don't try it at
the repl before posting, you WILL get it wrong :-).
On Mon, Mar 8, 2010 at 5:19 PM, Meikel Brandmeyer wrote:
>
>> (let [{:keys host port user password} config]
>> (.connect store host port user password))
>
> module missing
> (let [{:keys host port user password} config]
> (.connect store host port user password))
module missing [] around the keys. ;)
And of course this does not work for non-constant keylists. However I
think in the majority of cases the list should be constant.
--
You received this message be
Maybe just;
(let [{:keys host port user password} config]
(.connect store host port user password))
On Mon, Mar 8, 2010 at 9:47 AM, Michael Gardner wrote:
> Given a Java instance 'store' with a .connect method that takes a host, port,
> user and password, and given a hash-map 'config' with co
See memfn in Clojure API docs.
--
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
Given a Java instance 'store' with a .connect method that takes a host, port,
user and password, and given a hash-map 'config' with corresponding keyword
values, I wanted to do something like:
(apply .connect store (map config [:host :port :user :password]))
rather than:
(.connect store (:host
12 matches
Mail list logo