Re: Checking the form of an option
- To: mathgroup at smc.vnet.net
- Subject: [mg21170] Re: Checking the form of an option
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Fri, 17 Dec 1999 01:22:52 -0500 (EST)
- Organization: Universitaet Leipzig
- References: <831k39$dju@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
you must do it by hand.
One way is to make a function that has all options as parameters and a
wrapper that
extract the parameter values from the options. The second way is to make
functions that
expand the multiple values say you have a ImageSize option the may be
set to
Automatic, width and width and height of your image
makeImageSize[size_]:=
Switch[size,
Automatic, {256,256},
_Integer, {size,size},
{_Integer,_Integer}, size,
_, {256,256}
]
you may add some usefull error messages in the last case.
Hope that helps
Jens
DIAMOND Mark wrote:
>
> I want to check whether option "K" to a function is an integer, a list of
> single numbers, or neither of these, and then to execute one of three
> different statements.
>
> If these K were a simple parameter, I could do it with
> f[k_Integer] := functionBody;
> f[k:{_Integer}..] := functionBody;
> f[k_] := functionBody
>
> but I cannot see how to check for similar conditions on an *option* inside
> one function. Can anyone help?