MathGroup Archive 2007

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

Search the Archive

Re: Copy and Pasting Tables into Spreadsheet

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83453] Re: Copy and Pasting Tables into Spreadsheet
  • From: Gregory Lypny <gregory.lypny at videotron.ca>
  • Date: Wed, 21 Nov 2007 02:42:23 -0500 (EST)
  • References: <fhp2jd$1q6$1@smc.vnet.net> <fhu71j$70l$1@smc.vnet.net> <4742DFB0.20107@gmail.com>

Thank you Jean-Marc,

I'll look into this.  I'm also tinkering with a brute-force script  
that will flatten and then partition any table to create one with a  
depth of 3.  That should allow copying of numbers as plain text and  
then pasting them into other applications.

Gregory

On 20-Nov-2007, at 8:22 AM, Jean-Marc Gulliet wrote:

> gregory.lypny at videotron.ca wrote:
>
> <snip>
>
>> Is there a way to tell
>> Mathematica to return a scalar in all situations when the result  
>> would
>> otherwise be a list with only one element?
>
> Gregory,
>
> You could use the system variable *$Post* and set up your own post  
> processing function. (You might be interested in $PrePrint too.)  
> Here is an example of such a function that should do what you are  
> looking for, though you may want to add some additional tests (or  
> remove few of them).
>
> In[1]:= $Post =
>   If[Head[#] === List && Length[#] == 1 &&
>      Depth[#] < 3, #[[1]], #] &;
>
> prob = {.4, {.6}, {.4, .6}, {{.4, .6}}};
>
> prob[[1]] (* Scalar: not a list, depth one *)
> prob[[2]] (* List of length one and depth two *)
> prob[[3]] (* List of length two and depth two *)
> prob[[4]] (* List of length one and depth three *)
>
> $Post =. (* Reset $Post *)
>
> Out[3]= 0.4
>
> Out[4]= 0.6
>
> Out[5]= {0.4, 0.6}
>
> Out[6]= {{0.4, 0.6}}
>
> Best regards,
> -- 
> Jean-Marc



  • Prev by Date: Re: Solving Tanh[x]=Tanh[a]Tanh[b x + c]
  • Next by Date: Re: Copy and Pasting Tables into Spreadsheet
  • Previous by thread: Re: Copy and Pasting Tables into Spreadsheet
  • Next by thread: Re: Copy and Pasting Tables into Spreadsheet