You can use some Reflection to find out if the function has
implemented the matching invoke(args*) method

see: http://gist.github.com/654851

On 29 Okt., 07:02, Ken Wesson <kwess...@gmail.com> wrote:
> (defn accepts-arity? [n f]
>   (reduce
>     #(or
>        %1
>        (= n (count %2))
>        (and (= '& (last (butlast %2))) (>= n (- (count %2) 2))))
>    false
>    (:arglists (meta f))))
>
> This works only if f has metadata -- anonymous lambdas don't but functions
> defined using defn do.
>
> I thought this up while reading some intro to clojure.contrib.monad that
> mentioned that m-lift needs to be given an arity; it seems to me m-lift
> could probably be implemented to use the arities in the function metadata,
> when available, to make this optional.

-- 
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