Re: How to test if list of arguments are numeric
- To: mathgroup at smc.vnet.net
- Subject: [mg89545] Re: How to test if list of arguments are numeric
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Thu, 12 Jun 2008 02:59:57 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <g2nu84$ej1$1@smc.vnet.net>
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