       Re: Orderless indexed functions

• To: mathgroup at smc.vnet.net
• Subject: [mg20900] Re: Orderless indexed functions
• From: "Allan Hayes" <hay at haystack.demon.co.uk>
• Date: Sat, 20 Nov 1999 01:07:13 -0500 (EST)
• References: <812a0b\$1c4@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Some possibities:

In the following, g[x...,i] is the ordered version of the function that we
want for f[i][x...]

g[x_, y_, i_] := x^(y - i);

f[i_][x___] := g[##, i] & @@ Sort[{x}]
f[c, b]
Do[f[c, b], {3000}] // Timing

b^(-1 + c)

{2.04 Second, Null}

Clear[f]
f[i_][x__] := Function[{x}, g[x, i], Orderless][x]
f[c, b]
Do[f[c, b], {3000}] // Timing

b^(-1 + c)

{2.41 Second, Null}

For simple cases we can  avoid g

Clear[f]
f[i_][x_, y_] := Function[{x, y}, x^(y - i), Orderless][x, y]
f[c, b]
Do[f[c, b], {3000}] // Timing

b^(-1 + c)

{2.75 Second, Null}

--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

N Monomachoff <nmonomachoff at email.msn.com> wrote in message
news:812a0b\$1c4 at smc.vnet.net...
> Hello,
>
> I need to use 'indexed functions' like f[x__] and f[x__].
> It's important that the functions be Orderless, but
>
> SetAttributes[f,Orderless]
>
> isn't accepted because f isn't a symbol, and
>
> SetAttributes[f,Orderless]
>
> doesn't affect the ordering in the second set of brackets.
> How does one make a nonsymbolic head orderless?
>
> Thanks for any help.
>
> N Monomachoff
> nmonomachoff at msn.com
>
>
>

```

• Prev by Date: Re: Cryptography
• Next by Date: What kind of math problem is this?
• Previous by thread: Re: Pattern of a List of Pairs
• Next by thread: Re: Orderless indexed functions