MathGroup Archive 2006

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

Search the Archive

Re: when dimension increases

  • To: mathgroup at smc.vnet.net
  • Subject: [mg67594] Re: when dimension increases
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Sat, 1 Jul 2006 05:12:46 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <e82n4s$qvr$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Arkadiusz Majka wrote:
> Hi,
> 
> Imagine that I want to sort (or do anything else) a list
> 
> list={5,2,8,3}
> 
> So I use Sort[list]
> 
> Next I add next dimension and obtain a list listNew=Table[list,{5}]
> 
> In order to sort all sublists of it  it I use Map[Sort, listNew]
> 
> Now I add another more dimension listNew1=Table[list, {3},{5}]
> 
> I can again sort all sublists of it using combination of Table and Map.
> 
> The question is the following:
> 
> How can I deal with expresions of unknown a priori dimension? For
> example what is the most elegant (clear and fast) method of sorting all
> sublists of multidimensional expresion? I would like to avoid Table and
> unclear expresions with many "Maps" (one embeded in another).
> 
> Thanks for your help,
> 
> Arek
> 
Hi Arek,

Use level specification in the Map function [1]. For instance

In[1]:=
listNew4 = Table[Random[Integer, {0, 10}], {5}, {3},
     {5}, {2}, {4}, {7}];

In[2]:=
(Map[Sort, #1, Depth[#1] - 2] & )@listNew4;

The expression Depth[#1] - 2 returns the maximum number of indices one 
needs to reach all the non-atomic expressions. See [2] and [3] for 
detailed explanations on levels in expressions and level specifications 
and [4] for the built-in function *Depth*.

Best regards,
Jean-Marc

[1] http://documents.wolfram.com/mathematica/functions/Map

[2] http://documents.wolfram.com/mathematica/book/section-2.1.7

[3] http://documents.wolfram.com/mathematica/book/section-A.3.6

[4] http://documents.wolfram.com/mathematica/functions/Depth


  • Prev by Date: RE: when dimension increases
  • Next by Date: Re: when dimension increases
  • Previous by thread: RE: when dimension increases
  • Next by thread: Re: when dimension increases