       Re: Problem overriding simple built-in functions

• To: mathgroup at smc.vnet.net
• Subject: [mg28849] Re: Problem overriding simple built-in functions
• From: phbrf at t-online.de (Peter Breitfeld)
• Date: Tue, 15 May 2001 00:59:23 -0400 (EDT)
• References: <9dld4j\$o9b@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Jean-Christophe Deschamps <jchd at worldnet.fr> schrieb:
> Hi,
>
> I'm told the following occurs under Mathematica v4.0:
>
> In:= GCD[{3, 6}]
> Out= {3, 6}
> In:= GCD[x_List] := Apply[GCD, x]
> In:= GCD[{3, 6}]
> Out= GCD[{3, 6}]
> In:= Apply[GCD, {3, 6}]
> Out= 3
>
> Why is it so? It looks like the override is ignored, but why?
>
> The same exerpt seems to work fine under version 2.x.
>
Jean-Christophe,
first you have to unprotect GCD (but I think you did this, else there
would be an error-message). Then define:

In:= GCD[x_List]:=Apply[GCD,Sequence[x]]

Gruß Peter
--
=--=--=--=--=--=--=--=--=--=--=--=--=--= http://home.t-online.de/home/phbrf
Peter Breitfeld, Bad Saulgau, Germany   Meinen GnuPG/PGP-5x Key gibts dort

```

• Prev by Date: AW: Exponential Equations
• Next by Date: Re: Names[] for definitions in the current window/notebook?
• Previous by thread: Re: Problem overriding simple built-in functions
• Next by thread: RE: Re: Problem overriding simple built-in functions