Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*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 2005

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

Search the Archive

Re: Decimal comma on input

  • To: mathgroup at smc.vnet.net
  • Subject: [mg60545] Re: Decimal comma on input
  • From: "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de>
  • Date: Tue, 20 Sep 2005 05:18:59 -0400 (EDT)
  • Organization: Uni Leipzig
  • References: <dgm112$o3b$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

don't do that ! or what is
lst={2,3,4,5}

a four element list of integers or a
two elemement list of floats ?
How knows ?

Regards
  Jens

"Cca" <cca at gregosetroianos.mat.br> schrieb im 
Newsbeitrag news:dgm112$o3b$1 at smc.vnet.net...
| Here in Brazil our decimal separator is a comma. 
(This is the favoured convention in most non 
English-speaking countries.) We also put dots 
between each group of three digits. As an example, 
the number whose numeral is
|
| 1234.56789
|
| in USA is represented in Brazil as
|
| NumberForm[1234.56789, DigitBlock->{3,3},
|  NumberPoint->",", NumberSeparator->"."]
|
| or also (following the SI)
|
| NumberForm[1234.56789, DigitBlock->{3,3},
|  NumberPoint->",", NumberSeparator->" "]
|
| This said, it is natutal to ask: how to instruct 
Mathematica to recognize a decimal comma on input? 
My ad hoc
| solution is shown below, but I would be very 
interested in knowing alternative approaches.
|
| ---------------------------------------------
| Instead of a "true" comma, I use one with hidden 
information, namely
|
| TagBox[",", Identity, Editable->False, 
SyntaxForm->"."] // DisplayForm
|
| with the following rule (which will work, of 
course, only in the expected contexts):
|
| MakeExpression[RowBox[{a_,
| TagBox[",", Identity, Editable->False, 
SyntaxForm->"."], b_}], form_] := 
MakeExpression[StringJoin[a, ".", b], form]
|
| Now we can try, for example, 2,3*3,5, 2,3+1,45, 
etc.
| ---------------------------------------------
| Finally, to make it easy to insert the decimal 
comma above I provide four ways to the user:
|
| (1) a button:
|
| ButtonBox[",", ButtonData->
|   TagBox[",", Identity, Editable->False, 
SyntaxForm->"."]// DisplayForm
|
| (2) a rule for InputAliases (which overrides 
\[InvisibleComma]);
|
| (3) a keyboard shortcut, for which I add the 
following line to the file 
KeyEventTranslations.tr:
|
| Item[KeyEvent["KeypadDecimal"], FrontEndExecute[
| 
{FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],
| TagBox[",", Identity, Editable->False, 
SyntaxForm->"."], After]}]]
|
| (4) a menu command (not well tested yet):
|
| LinkWriteHeld[$ParentLink,
| Hold@AddMenuCommands["New",
|     {Item["Decimal comma",
|         FrontEndExecute[{
| 
FrontEnd`NotebookWrite[FrontEnd`InputNotebook[], 
TagBox[",", Identity, Editable->False, 
SyntaxForm->"."], After]}]]}]]
| ---------------------------------------------
|
| Carlos César de Araújo
| Gregos & Troianos Educacional
| www.gregosetroianos.mat.br
| Belo Horizonte, MG, Brazil
| (31) 3283-1122
| 



  • Prev by Date: Re: 'Changing' parameters in an expression
  • Next by Date: Re: Differences between recursions and limit
  • Previous by thread: Decimal comma on input
  • Next by thread: A Su Doku solver