Interesting -- it's certainly more generic than the solution that I have
worked up. I'd need to add something for the variadic fall-back call.
Thank you!
Francis Avila writes:
> This is exactly the approach to take: a macro which expands to a defn with
> all your arities filled out.
>
> Here
Fluid Dynamics writes:
>> (defn ^:private form-with-arity[n]
>> ;; left as an exercise for the reader
>> )
>>
>> (defmacro ^:private m-default-ontology
>> `(defn default-ontology
>> ~@(map form-with-arity (range 1 10
>>
>> (m-default-ontology)
>>
>> Or am I missing somethi
This is exactly the approach to take: a macro which expands to a defn with
all your arities filled out.
Here's a simple approach which might be enough for your problem: it will
splice in argument names whenever some marker symbol is encountered, and
repeat for the range of arities you want.
(
On Thursday, June 4, 2015 at 12:55:23 PM UTC-4, Phillip Lord wrote:
>
>
> I have a number of fairly nasty functions with a form that looks like
> this:
>
> (defn default-ontology
> ([f]
> (dispatch f))
> ([f a]
> (dispatch f a))
> ([f a b]
> (dispatch f a b))
> ([f a
I have a number of fairly nasty functions with a form that looks like
this:
(defn default-ontology
([f]
(dispatch f))
([f a]
(dispatch f a))
([f a b]
(dispatch f a b))
([f a b c]
(dispatch f a b c))
([f a b c d]
(dispatch f a b c d))
([f a b c d e]
(dispa