# Take Elements of a List [duplicate]

I want to delete the first element of a list of a list in Mathematica. For example I have:

x= {{{1,2},{4,5,6},{7,8,9}},{{10,11},{13,14,15},{16,17,18}}}


I want the answer like this:

{{{4,5,6},{7,8,9}},{{13,14,15},{16,17,18}}}

How can I do that??

Thanks

• If anyone disagrees with closing, please let me know.
– Kuba
Dec 11, 2017 at 15:04

One way would be to evaluate

Map[Rest, x, 1]


which returns

{{{4, 5, 6}, {7, 8, 9}}, {{13, 14, 15}, {16, 17, 18}}}


Similarly,

Drop[x, None, 1]


returns the same output.

edit: The second way is probably the faster of the two

x[[All, 2 ;;]] (* or x[[;; , 2 ;;]] *)


{{{4, 5, 6}, {7, 8, 9}}, {{13, 14, 15}, {16, 17, 18}}}

Also:

☺ = {##2} & @@@ # &;
☺ @ x
> {{{4, 5, 6}, {7, 8, 9}}, {{13, 14, 15}, {16, 17, 18}}}

 Cases[x, {{__}, {a__}, {b__}} :> {{a}, {b}}]


In addition to the previous answers you can use the function Delete

Delete[{{{1, 2}, {4, 5, 6}, {7, 8, 9}}, {{10, 11}, {13, 14, 15}, {16,
17, 18}}}, {{1, 1}, {2, 1}}]


The resulting

{{{4, 5, 6}, {7, 8, 9}}, {{13, 14, 15}, {16, 17, 18}}}

x = {{{1, 2}, {4, 5, 6}, {7, 8, 9}}, {{10, 11}, {13, 14, 15}, {16, 17, 18}}};

y = x;
y[[All, 1]] = Nothing;
(*or*)
y2 = Drop[x, 0, 1];

y === y2

True