|
[Date Index]
[Thread Index]
[Author Index]
Re: How to create a new Form
- To: mathgroup at smc.vnet.net
- Subject: [mg58802] Re: How to create a new Form
- From: "Carl K. Woll" <carlw at u.washington.edu>
- Date: Tue, 19 Jul 2005 04:10:10 -0400 (EDT)
- Organization: University of Washington
- References: <dbd114$2sp$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
"Nilton" <nilton.volpato at ig.com.br> wrote in message
news:dbd114$2sp$1 at smc.vnet.net...
>I would like to create a new Form that is a "wrapper" (like Short,
> CForm, ...), which affects printing, but not evaluation. For example:
>
> In[1]:= 10 + f[5] // BinaryForm
>
> Out[1]//BinaryForm =
> 1010 + f[101]
>
> In[2]:= %
> Out[2]= 10 + f[5]
>
> I know there is BaseForm, but this is just an example. In fact I would
> like to do something more complicated, but must know how to do
> something like this first.
>
> Can anyone help?
>
> Thanks,
> -- Nilton
>
The following is a bit of a hack, but it seems to work.
In[1]:=
Format[BinaryForm[expr_],BinaryForm]:=expr
Format[BinaryForm[expr_]]:=
expr /. a_Integer :> FromDigits[IntegerDigits[a,2]]
In[3]:=
10+f[5]//BinaryForm
Out[3]//BinaryForm=
1010 + f[101]
In[4]:=
%
Out[4]=
10+f[5]
Carl Woll
Wolfram Research
Prev by Date:
Re: Validating functions input
Next by Date:
Re: Validating functions input
Previous by thread:
Re: Re: How to create a new Form
Next by thread:
Re: How to create a new Form
|