MathGroup Archive 2005

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

Search the Archive

Re: How to create a new Form

Nilton schrieb:
> Thanks for the answers, but it's not what I want... :(
> I know I can use BaseForm to do this (as I told), and I know how to use
> format to format expression on any Form that is built-in to Mathematica
> (like: CForm, FortranForm, InputForm, StandardForm, etc.). This is what
> documentation explain.
> What I want to know, is how to create my own "output form". This
> BinaryForm is just a simple example, in fact what I want to do is more
> complicated (and I tried to simplify the question).
> yehuda: I looked at Combinatorica, but found just a formatting rule for
> graphs, and not and example of how to create a new output form.
> Maybe someone from Wolfram staff could help me?
> Thanks,
> -- Nilton
> Peter Pein wrote:
>>Have a look at the documentation (and example) for Format[]: either on
>>your hard disk or here:
>>Peter Pein

Dear Nilton,

may I - again - lead your attention to the documentation of Format[]?
In the (so called further) example you'll find exactly what you're
looking for:

Another example:
Let's assume you want to build a form that shows a list of zeros and
ones as a run length encoded form with the first element of the original
list as first element and the lengths of the runs of the digis as second
element and you want to call it RLEForm.

Format[RLEForm[l_]] := {First[l], Length /@ Split[l]}

and you can already use it like FullForm and friends:

lst = Table[Random[Integer], {10}]

{1, 1, 0, 1, 1, 0, 0, 0, 1, 0}
{1, {2, 1, 2, 3, 1, 1}}

And in a similar way you can do this with more complicated conversions:

myConv[expr_Integer]:=....a lot of code for integer arguments...
myConv[expr_]:=...same for other domains...

that's it.

But maybe I've mistaken your question again - so I'll better shut up
before becoming a "pein" in the neck.

Peter Pein

  • Prev by Date: Mathematica 5.2: The 64-bit and multicore release Dear Mathematica User, Mathematica 5.2--the 64-bit computing and multicore release--is now available! Mathematica 5.2 brings 64-bit technology to all supported platforms--an industry first. In addition, 5.2 enables threading of numerical linear algebra over multiple CPUs or multicore computers, making Mathematica an ideal environment for large computations and simulations. We know you will also appreciate this version's many other improvements. Upgrading will get you: * 64-bit-enhanced arbitrary-precision numerics * Vector-based performance enhancements * Automatic binary installation selection * Bundled notebook indexing for desktop search * SSH support for secure remote kernels * vCard and RSS import/export * New algorithms for symbolic differential equations * Enhanced performance for linear Diophantine systems * Enhanced quadratic quantifier elimination * Singular-case support for high-level special functions * Enhanced statistics charts * MathematicaMark 5.2 benchmark now covering grids and clusters See examples, explanations, and details at: As a special offer, you can save 50% on your upgrade by ordering Premier Service ( at the same time. Upgrade now at or contact Customer Service using the information that follows this message. Use our download option and you could be up and running within an hour. Enjoy Mathematica 5.2! Sincerely, The Mathematica Product Team Wolfram Research +++++++++++++++++++++++++++++++++++++++++++++ Wolfram Research Customer Service In the U.S. and Canada: Call us at +1-800-WOLFRAM (965-3726) or send email to In the UK and Ireland: Call us at +44-(0)1993-883400 or send email to Elsewhere, please contact your local reseller listed at: +++++++++++++++++++++++++++++++++++++++++++++
  • Next by Date: Re: Re: Diagonalizing a non-Hermitian Matrix
  • Previous by thread: Re: How to create a new Form
  • Next by thread: How to create a new Form