MathGroup Archive 1996

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re:Function & Format


F Renard wrote:
> 

> Can anyone tell me how to construct a function that doesn't PRINT
> the real result, but any string instead (like "-Graphics-")
> (If it is possible !)
> 

> Example:
> 

> In[1]:= fun[x_]:= x^2
> 

> In[2]:= fun[3]
> 

> Out[2]= -FUN-
> 

> In[3]:= %+1
> 

> Out[3]= 10
> 

> I don't know if the function Format is useful for that...


You can give definitions for fun that generate the example above.

Clear[fun,Coat];
fun[a_]:=Coat[a^2];
Format[Coat[_]]:= "-Fun-";
g_[a___,Coat[b___],c___]^:=g[a,b,c];

If you change the value of your function fun, you must clear the  
values of Coat!!

In[34]:=
  fun[3]
Out[34]=
  -Fun-
In[35]:=
  % + 1
Out[35]=
  10

Frans Martens
Eindhoven 

The Netherlands






  • Prev by Date: Q about Mathematica 3.0 Student ver
  • Next by Date: Re: Problem with QuicKeys & Mathematica
  • Previous by thread: Re: Q about Mathematica 3.0 Student ver
  • Next by thread: Re: Problem with QuicKeys & Mathematica