MathGroup Archive 2001

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

Search the Archive

Re: Counting Elements in a List

  • To: mathgroup at smc.vnet.net
  • Subject: [mg27970] Re: Counting Elements in a List
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Tue, 27 Mar 2001 01:26:07 -0500 (EST)
  • References: <99n61j$ihj@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

John:

mylist = {{1, 2, 3, 4}, {1, 2, 3, 5}, {1, 3, 4, 6}, {1, 3, 6, 9}, {2, 4,
7,8}};


Count[mylist, x_/;x[[4]]>5]

        3

--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

"JOHN C ERB" <JOHN_C_ERB at prodigy.net> wrote in message
news:99n61j$ihj at smc.vnet.net...
> I have a list in which I want to count the number of times the 4th element
> (i.e., 4th column) meets certain specifications (e.g., where it greater
than
> or equal to 8).
>
> I can do this by:
>
> mylist = {{1, 2, 3, 4}, {1, 2, 3, 5}, {1, 3, 4, 6}, {1, 3, 6, 9}, {2, 4,
7,
> 8}};
> Length[Select[mylist, #[[4]] >= 8 &]]
>
> Surely, there is another, more direct, way of doing this using Count?
>
>
> Thank you,
>
> John C. Erb
>
> email: John_C_Erb at prodigy.net
>
>




  • Prev by Date: RE: Counting Elements in a List
  • Next by Date: Re: Counting Elements in a List
  • Previous by thread: RE: Counting Elements in a List
  • Next by thread: Re: Counting Elements in a List