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: [mg27967] Re: [mg27959] Counting Elements in a List
  • From: BobHanlon at aol.com
  • Date: Tue, 27 Mar 2001 01:26:05 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

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 &]]

2

Count[mylist, _?(#[[4]] >= 8&)]

2

Count[mylist, x_ /; x[[4]] >= 8]

2

Bob Hanlon

In a message dated 2001/3/26 5:49:23 AM, JOHN_C_ERB at prodigy.net writes:

>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?
>


  • Prev by Date: Re: Number Theory - Chinese Remainder Theorem
  • Next by Date: Real (but trivial) interface "bug" (deficiency) in Mac 4.0 front end
  • Previous by thread: Counting Elements in a List
  • Next by thread: RE: Counting Elements in a List