MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Test function argument with VectorQ and NumericQ

  • To: mathgroup at smc.vnet.net
  • Subject: [mg107322] Re: Test function argument with VectorQ and NumericQ
  • From: Szabolcs Horvát <szhorvat at gmail.com>
  • Date: Tue, 9 Feb 2010 02:45:08 -0500 (EST)
  • References: <hkp1na$7fh$1@smc.vnet.net>

On 2010.02.08. 13:57, Oliver Fochler wrote:
> Hi there,
>
> in order to get my NIntegrate running properly it seems that I need to
> ensure that my functions actually take numeric arguments (without
> NIntegrate trying to do some symbolic stuff before).
>
> For a simple case something like
>
> f[x_?NumericQ] := (stuff)
>
> seems to work fine. However, I do use vectors (lists) as function
> arguments, i.e. f[x_, y_]:= (stuff) needs to be called as f[ {1,2,3},
> 4].
> How do I test this for numerical values? I know that I can use
> VectorQ[ x, NumericQ ] to check whether x is a vector that contains
> only numeric values.
>
> But how do I combine this into a pattern test, that can be used in an
> argument list?
> I would appreciate any help!

You can use for example f[ x_ ? (VectorQ[#, NumericQ]&) ] := ...


  • Prev by Date: Re: NDSolve with Dirichlet boundary condition
  • Next by Date: Re: How fast does & perform?
  • Previous by thread: Re: Test function argument with VectorQ and NumericQ
  • Next by thread: Re: Test function argument with VectorQ and NumericQ