RE: List Manipulation
- To: mathgroup@smc.vnet.net
- Subject: [mg10493] RE: [mg10471] List Manipulation
- From: Ersek_Ted%PAX1A@mr.nawcad.navy.mil
- Date: Tue, 20 Jan 1998 02:22:43 -0500
Paul Hanson wrote: | If I have a list of n lists, and want to | get rid of all the even ones how would I go about doing this? That | is, {{n1},{n2},.....{2n}} converted to {{n1},{n3}...{2n-1}}. I tried | using the various procedures in Wolfram's book, but nothing seems to | work (ie, Delete, Take, etc.). In the example below I Select all Lists that do not contain an even number. If you want all Lists that contain a string that meets some condition that is a different matter. In[1]:= Clear[a,b]; lst={{1},{5},{a},{2},{7},{4},{b},{2/3},{2.3},{2},{3}}; Select[lst, Not[EvenQ@@#]& ] Out[1]= {{1},{5},{a},{7},{b},{2/3},{2.3},{3}} Note: @@ is short hand for Apply. (EvenQ@@expr) takes the Head off of expr and replaces it with EvenQ and finishes evaluation from there. Ted Ersek