MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: List Manipulation




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




  • Prev by Date: Drawing multiple curves with ParametricPlot3D
  • Next by Date: Re: ReplacePart?
  • Prev by thread: Re: List Manipulation
  • Next by thread: Re: List Manipulation