Re: How to test if list of arguments are numeric
- To: mathgroup at smc.vnet.net
- Subject: [mg89533] Re: How to test if list of arguments are numeric
- From: "Michael A. Gilchrist" <mikeg at utk.edu>
- Date: Thu, 12 Jun 2008 02:57:42 -0400 (EDT)
- References: <g2nu84$ej1$1@smc.vnet.net> <484FB895.6070505@gmail.com>
Hi Jean (and Oliver and Szabolcs),
Thank you all for your solutions. I didn't realize that VectorQ could take
that optional argument.
Mike
On Wed, 11 Jun 2008, Jean-Marc Gulliet wrote:
> Michael A. Gilchrist wrote:
>
>> I'm trying to use a function with NMinimize and running into problems with
>> holding off its evaluation until NMinimize passes real values.
>> Essentially, I have something like this
>>
>> TestFunction[avec_]:=Module[{},
>> ..
>> ..
>> ..
>> ]
>>
>> Where avec should be a list of real numbers. I know that to ensure avec is
>> a list I use avec_?ListQ, but I need to ensure that avec is a list of real
>> numbers (not the symbols that NMinimizes passes).
>>
>> Unfortunately, I have no idea what the correct syntax is. Could someone
>> please clue me in on this?
>
> The following should do it:
>
> TestFunction[avec_?(VectorQ[#, NumericQ] &)]:=Module[{},
> ..
> ..
> ..
> ]
>
> See "How do I write a function which evaluates only when the argument is a
> number?" at
>
> http://support.wolfram.com/mathematica/kernel/features/evalwhennumber.html
>
> Regards,
> -- Jean-Marc
>