Re: To create {{},{},....{}} beyond $MaxRecursionLimit
- To: mathgroup at smc.vnet.net
- Subject: [mg46726] Re: To create {{},{},....{}} beyond $MaxRecursionLimit
- From: "Curt Fischer" <crf3 at po.cwru.edu>
- Date: Wed, 3 Mar 2004 02:30:36 -0500 (EST)
- References: <c238e9$igj$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
In[1]:=
nester[n_Integer]:=nester[n]=Append[nester[n-1],{}];nester[0]={};
In[2]:=
nester[7]
Out[2]=
{{},{},{},{},{},{},{}}
This method will still complain if you ask for a list of a length greater
than $MaxRecursionLimit, but you don't need to change $MaxRecursionLimit to
Infinity if you don't want. Just pick a number one greater than the length
of the list you want to make ; )
--
Curt
J疣os wrote:
> Hi,
>
> I am in need of creating a nested list in the form of {{},{},....{}}
> of arbitrary length where none of the sublists have any element in it.
> I came up with
>
> lst = NestList[List, {},lengthlist - 1]
>
> For[i = 2, i <=
> lengthlist, i++, flt = Table[{j}, {j, i, lengthlist}]; lst =
> FlattenAt[lst, flt]]
>
> however it complains when lengthlen is over $MaxRecursionLimit. I
> see that I can change that Limit to Infinity, but I rather would not
> go that route. It must be a better way without using NestList.
>
> Any good hint ?
>
> Thanks ahead,
>
> J疣os
> -------------------------------------------------
> clear perl code is better than unclear awk code; but NOTHING comes
> close to unclear perl code
> http://www.faqs.org/faqs/computer-lang/awk/faq/