Re: Drop elements from list
- To: mathgroup at smc.vnet.net
- Subject: [mg94189] Re: [mg94161] Drop elements from list
- From: "Adriano Pascoletti" <adriano.pascoletti at gmail.com>
- Date: Sat, 6 Dec 2008 19:57:14 -0500 (EST)
- References: <200812061114.GAA16053@smc.vnet.net>
Sigmund, if L denotes a list of pairwise disjoint intervals a folded Drop solves the problem: Fold[Drop[#1, #2] &, a, Reverse@Sort[L]] Test: In[3]:= L = {{2, 5}, {7, 10}}; Fold[Drop[#1, #2] & , 100 + Range[20], Reverse[Sort[L]]] Out[3]= {101, 106, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120} Adriano Pascoletti 2008/12/6 SigmundV <sigmundv at gmail.com>: > 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 > >
- References:
- Drop elements from list
- From: SigmundV <sigmundv@gmail.com>
- Drop elements from list