MathGroup Archive 2003

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

Search the Archive

Re: Count pattern

  • To: mathgroup at smc.vnet.net
  • Subject: [mg41313] Re: Count pattern
  • From: "Timo Koerber" <koerber at u.washington.edu>
  • Date: Wed, 14 May 2003 08:13:39 -0400 (EDT)
  • Organization: University of Washington
  • References: <b9qabm$htm$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Here's the answer:

t = {1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 17, 27, 28, 30, 36, 50};
s = {1, 1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 8, 10, 12, 12, 14, 17, 20, 27, 27, 28,
      30, 30, 36, 38, 40, 45, 50, 50, 50, 63, 132, 132};
f[l1_, l2_] :=
    Table[Length[Select[l1, #1 \[GreaterEqual] l2[[x]] &]], {x, 1,
        Length[l2]}];
f[s, t]
=>{33, 30, 28, 27, 26, 25, 24, 23, 21, 20, 18, 17, 15, 13, 12, 10, 6}


Timo Koerber,
University of Washington, Physics



"Søren Merser" <merser at image.dk> wrote in message
news:b9qabm$htm$1 at smc.vnet.net...
>
> hi there
>
> i need a litle help on a problem that has puzzeled me for some time
>
> i want to count the number of elements in s with value greater or equal
> to each element in t
>
> t = {1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 17, 27, 28, 30, 36, 50}
>
> s = {1, 1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 8, 10, 12, 12, 14, 17, 20, 27,
> 27, 28, 30, 30, 36, 38, 40, 45, 50, 50, 50, 63, 132, 132}
>
> the result should be: {33, 30, 28, 27, 26, 25, 24, 23, 21, 20, 18, 17,
> 15, 13, 12, 10, 6}
>
>
>
> kind regards soren
>
>




  • Prev by Date: Re: Count pattern
  • Next by Date: Re: Apart, Factor on different operations
  • Previous by thread: Re: Count pattern
  • Next by thread: Re: Count pattern