# How can I use a sublist in place of the full list in a computation [closed]

How can I use a sublist in place the full list in a computation, but refer to it by the name of the full list.

I have a list

allData={{a, b, c}, {a1, b1, c1}, {a2, b2, c2}, {a3, b3, c3}};


For a particular evaluation I would like to get rid of the last 2 parts to get

allData = {{a, b, c}, {a1, b1, c1}};


But for a different evaluation I want to keep everything.

So is there a way how to quickly uncomment Delete or replace the part specification with... nothing?

Delete[allData(*,{{3},{4}}*)]


returns, obviously,

Delete[{{a, b, c}, {a1, b1, c1}, {a2, b2, c2}, {a3, b3, c3}}]

Of course, in reality Delete is just one of many functions applied to allData.

## closed as off-topic by MarcoB, Daniel Lichtblau, Henrik Schumacher, Alex Trounev, Carl LangeApr 4 at 17:09

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, Daniel Lichtblau, Henrik Schumacher, Alex Trounev, Carl Lange
If this question can be reworded to fit the rules in the help center, please edit the question.

• Use an empty list. – J. M. is away Apr 3 at 13:26
• Are you aware of the keyboard shortcut for commenting / uncommenting? You can select code and, on Windows, press Alt + / to toggle the comment status of your selection. – MarcoB Apr 3 at 13:37
• @J.M.isslightlypensive Should I delete this question? Because your answer, obviously, works. Thank you. – Mefistofelis Apr 3 at 13:37
• Probably I did not understand you right, but what I get from your question is a feeling that you are afraid to spoil the list allData, right? If yes, nothing forces you to change the allData list. Why do not you create a new list like allDataNew=Take[allData,2]? – Alexei Boulbitch Apr 3 at 13:39
• @MarcoB or left click + u. Yes, I am aware of that. The embarrassing problem was that I had no clue how 'empty list' would work. – Mefistofelis Apr 3 at 13:40

I would not fool around with Delete or commenting or uncommenting. Instead I would enclose the particular computation that needs only the 1st two elements in Block.

Example

data = {{a, b, c}, {a1, b1, c1}, {a2, b2, c2} ,{a3, b3, c3}};
Block[{data = data[[;; 2]]}, data^2]


{{a^2, b^2, c^2}, {a1^2, b1^2, c1^2}}

But data is unchanged.

data

{{a, b, c}, {a1, b1, c1}, {a2, b2, c2} ,{a3, b3, c3}};