From: Murray Eisenberg on 12 Nov 2009 06:02 That NumberForm does not have attribute Listable does not seem to be the whole story, since in fact NumberForm does act upon the individual numbers in a List when it directly displays that list. For example: n1 = RandomReal[100, 2]; NumberForm[n1, {3, 3}] {68.900,6.860} Bob Hanlon wrote: > n1 = RandomReal[100, 10]; > > (n2 = NumberForm[n1, {3, 3}])//FullForm > > Look at the FullForm of your n2. Then note that NumberForm does not have the attribute Listable. > > Attributes[NumberForm] > > {Protected} > > Use > > n2 = NumberForm[#, {3, 3}] & /@ n1; > > Column[n2, Right] > > > Bob Hanlon > > ---- BenT <brtubb(a)pdmusic.org> wrote: > > ============= > Please consider these Mathematica 7 code Input lines: > > n1 = RandomReal[100, 10] > > n2 = NumberForm[n1, {3, 3}] > > Column[n2, Right] > > What I expected to get was "ignored", namely right aligned "arbitrary" > numeric data with 3 digits to the right, and 3 digits to the left of > the decimal point) formatted in a single column. How can this be > achieved with any numeric list of data? > > --- Benjamin Tubb > > > -- > > Bob Hanlon > > -- Murray Eisenberg murray(a)math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305
From: BenT on 12 Nov 2009 06:06 Thanks to all for your replies. The distinction of an output format "overiding" evaluation as a List, will be kept in mind, and the "workaround" suggested, espcially with the Map ("/@") function applied instead. --- Benjamin Tubb
From: DrMajorBob on 13 Nov 2009 05:57 > ..which shows a NumberForm expression. Remember that NumberForm does not > affect evaluation, only display. That's simply NOT true in any meaningful sense, and that's the source of the current problem. For it to be true, most (all?) operations must automatically move "through" NumberForm to the numbers. Not just + and -, but also Column and others. Column[Numberform[...]]] needs to become NumberForm[Column[...]] in the same way that Plus and Minus should (but don't) do the same thing. Your statement above implies that at least the arithmetic operations go through... and they don't. Bobby On Thu, 12 Nov 2009 05:00:24 -0600, Murray Eisenberg <murray(a)math.umass.edu> wrote: > You may obtain what you want by mapping the appropriate NumberForm > expression onto the list n1 and feeding that into Column (for the sake > of this post, I shortened the list to have length 2): > > n1 = RandomReal[100, 2]; > n2 = NumberForm[#, {3, 3}] & /@ n1; > Column[n2, Right] > 91.900 > 56.100 > > I don't know how completely to explain why what you tried doesn't work, > except to note the result of ... > > NumberForm[n1, {3, 3}] // FullForm > > ..which shows a NumberForm expression. Remember that NumberForm does not > affect evaluation, only display. > > But I've long considered the same effect you observed as an a > Mathematica annoyance. Like you, I've always expected the NumberForm to > change the display of all the numbers no matter where they're > subsequently embedded. > > I don't know why this annoying behavior cannot be changed, although from > my perspective it's hard to tell what effects the change might make as > they ricochet through the whole system. > > BenT wrote: >> Please consider these Mathematica 7 code Input lines: >> >> n1 = RandomReal[100, 10] >> >> n2 = NumberForm[n1, {3, 3}] >> >> Column[n2, Right] >> >> What I expected to get was "ignored", namely right aligned "arbitrary" >> numeric data with 3 digits to the right, and 3 digits to the left of >> the decimal point) formatted in a single column. How can this be >> achieved with any numeric list of data? >> >> --- Benjamin Tubb >> > -- DrMajorBob(a)yahoo.com
First
|
Prev
|
Pages: 1 2 3 Prev: integral of exponential Next: kernel crash with integrating the derivative of an |