Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #15664 > unrolled thread

Re: Mixing optional parameters and options

Started bythomas <thomas.muench@gmail.com>
First post2011-02-04 06:38 +0000
Last post2011-02-04 06:38 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Mixing optional parameters and options thomas <thomas.muench@gmail.com> - 2011-02-04 06:38 +0000

#15664 — Re: Mixing optional parameters and options

Fromthomas <thomas.muench@gmail.com>
Date2011-02-04 06:38 +0000
SubjectRe: Mixing optional parameters and options
Message-ID<iig6sg$rdl$1@smc.vnet.net>
See here for a solution to this problem, provided by Leonid Shifrin:

http://groups.google.com/group/comp.soft-sys.math.mathematica/browse_frm/thread/35ff6cf97d5019ec/df1b14a433eb2fa6?lnk=gst&q=Functions+with+variable+number#df1b14a433eb2fa6

thomas

On Feb 3, 11:34 am, Peter Breitfeld <ph...@t-online.de> wrote:
> To give a simpe example which, I hope, makes clear my issue:
> Suppose I define this (silly) example function:
>
> Options[f]={bla->True};
> f[x_,y_:11,OptionsPattern[]:=If[OptionValue[bla],x*y,y/x]
>
> Now:
> f[5]    ----> 55 (ok)
> f[5,7]  ----> 35 (ok)
>
> f[5,7,bla->False]  ----> 7/5 (ok)
> f[5,bla->False]    ----> 5*(bla->False)
>
> I expected the result 11/5
>
> The only way I found was to define f like this:
>
> f[{x_,y_:11},OptionsPattern[]]
>
> Can it be done without the curly braces?
>
> Thank you
> --
> _________________________________________________________________
> Peter Breitfeld, Bad Saulgau, Germany --http://www.pBreitfeld.de

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web