How about having an optional ndims argument at least, for non-REPL usage?

On Sat, Mar 28, 2015 at 9:30 PM, Sheehan Olver <[email protected]>
wrote:

> It currently works like this, which does work with f(x)=x, f(x,y) = x+y:
>
> try
>         f(0)
> catch
>         try
>                 f(0,0)
>         catch
>                 f((0,0))
>         end
> end
>
> This code is meant for REPL usage primarily, and so the convenience of
> typing just Fun(f) is worth having such “questionable” code.
>
>
> > On 29 Mar 2015, at 6:29 am, Mauro <[email protected]> wrote:
> >
> >> In ApproxFun, a user supplied function is approximated.  the
> >> approximation depends on whether the function is univariate or
> >> bivariate
> >
> > How does it work, if the user defines several methods?
> >
> > f(x) = x
> > f(x,y) = x+y
> >
> >>> The method_exists function would probably be a slightly cleaner way
> >>> to do this.
> >
> > method_exists should be good for generic functions but it does not work
> > with anonymous functions.  I think this gives you the number of
> > arguments:
> >
> > length(Base.uncompressed_ast(( (x,y,z)->1 ).code.def).args[1])
> >
> > something similar should let you figure out whether a one-argument
> > signature is a tuple.  Not sure though this is the preferred approach.
>
>

Reply via email to