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


Groups > comp.soft-sys.math.mathematica > #11264

Re: Symmetrizing function arguments

From "Nasser M. Abbasi" <nma@12000.org>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Symmetrizing function arguments
Date 2012-08-08 07:16 +0000
Message-ID <jvt3oc$lum$1@smc.vnet.net> (permalink)
References <jvqem1$gtt$1@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


On 8/7/2012 2:04 AM, Hauke Reddmann wrote:

> g[a_,b_,c_]:=If[b>c,If[a>c,If[a>b,G[a,b,c],g[b,a,c]],g[c,b,a]],g[a,c,b]];

why not simply use Sort, that is what you are doing above?

You can defined your G to take a list as in {a_,b_,c_} from Sort
or use Sequence to splice the result from Sort before calling G.

Here is one example:

-----------------------
G[{a_, b_, c_}] := Print["a=", a, " b=", b, " c=", c]
g[a_, b_, c_] := G[Sort[{a, b, c}, #1 > #2 &]]
---------------------------

And another using Sequnece, so you do not need to change
G defintion

-----------------------
G[a_, b_, c_] := Print["a=", a, " b=", b, " c=", c]
g[a_, b_, c_] := G[Sequence @@ Sort[{a, b, c}, #1 > #2 &]]
---------------------------

--Nasser

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Symmetrizing function arguments Hauke Reddmann <fc3a501@uni-hamburg.de> - 2012-08-07 07:04 +0000
  Re: Symmetrizing function arguments "Nasser M. Abbasi" <nma@12000.org> - 2012-08-08 07:16 +0000
    Re: Symmetrizing function arguments Hauke Reddmann <fc3a501@uni-hamburg.de> - 2012-08-09 01:37 +0000

csiph-web