Re: How to work with In?

*To*: mathgroup at smc.vnet.net*Subject*: [mg114067] Re: How to work with In?*From*: Oliver Ruebenkoenig <ruebenko at wolfram.com>*Date*: Mon, 22 Nov 2010 07:39:51 -0500 (EST)

On Sat, 20 Nov 2010, kj wrote: > In <ic5opg$70l$1 at smc.vnet.net> Oliver Ruebenkoenig <ruebenko at wolfram.com> writes: > >> On Fri, 19 Nov 2010, kj wrote: > >>> I want to create a list consisting of the (unevaluated) expressions >>> that were entered in a particular subrange of the In array. I.e., >>> what I want is (almost) something like this: >>> >>> Table[In[i], {i, 300, 375}] >>> >>> except that this won't work, because each In[i] will be evaluated. >>> This also fails >>> >>> Table[Hold[In[i]], {i, 300, 375}] >>> >>> because now the i is not evaluated, so the result is a list of >>> multiple copies of the expression Hold[In[i]]. >>> >>> How can I do what I'm trying to do? > >> I think this is your friend > >> Table[With[{i = i}, Hold[In[i]]], {i, 300, 375}] > > > That's one cool trick! Thanks! With is used to inject code into held expressions. > > Unfortunately, it doesn't solve this problem: > > In[31]:= Table[With[{i = i}, Hold[In[i]]], {i, 20, 30}] > > Out[31]= {Hold[In[20]], Hold[In[21]], Hold[In[22]], Hold[In[23]], > Hold[In[24]], Hold[In[25]], Hold[In[26]], Hold[In[27]], Hold[In[28]], > Hold[In[29]], Hold[In[30]]} > > I need each of In[20], In[21], ..., In[30] to be processed by the > kernel exactly once before clamping the result with Hold. > ReleaseHold[Table[With[{i = i}, Hold[In[i]]], {i, 1, 4}] ] > By the way, being able to limit the level of evaluation to a precise > number of "passes", greater than zero, but not all the way to full > evaluation, is something I find myself needing very often. > > ~kj > >