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[1]:= GCD[{3, 6}] > Out[1]= {3, 6} > In[2]:= GCD[x_List] := Apply[GCD, x] > In[3]:= GCD[{3, 6}] > Out[3]= GCD[{3, 6}] > In[4]:= Apply[GCD, {3, 6}] > Out[4]= 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[2]:= 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