(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 [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to