Re: Drop elements from list
- To: mathgroup at smc.vnet.net
- Subject: [mg94200] Re: [mg94161] Drop elements from list
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Sat, 6 Dec 2008 19:59:13 -0500 (EST)
- Reply-to: hanlonr at cox.net
a = Array[x, {20}]; Drop[Drop[a, {7, 10}], {2, 5}] {x(1),x(6),x(11),x(12),x(13),x(14),x(15),x(16),x(17),x(18),x(19),x(20)} Fold[Drop[#1, #2] &, a, {{7, 10}, {2, 5}}] {x(1),x(6),x(11),x(12),x(13),x(14),x(15),x(16),x(17),x(18),x(19),x(20)} Or slightly more succinctly with Fold Fold[Drop[##] &, a, {{7, 10}, {2, 5}}] {x(1),x(6),x(11),x(12),x(13),x(14),x(15),x(16),x(17),x(18),x(19),x(20)} % == %% == %%% True Bob Hanlon ---- SigmundV <sigmundv at gmail.com> wrote: ============= Dear group, Consider a list of length, say, 20: a = RandomReal[{},20]; How would you then drop/delete elements, say, 2-5 and 7-10 from this list? The built-in function Drop does not seem to include such a possibility. I should add that I do not have access to Mathematica 7, so any solution should work in version 6. Kind regards, Sigmund