Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1996
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1996

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

Search the Archive

Re: Re:Function & Format

  • To: mathgroup at smc.vnet.net
  • Subject: [mg5143] Re: [mg5107] Re:Function & Format
  • From: fransm at win.tue.nl (Frans Martens)
  • Date: Wed, 6 Nov 1996 01:33:08 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

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