MathGroup Archive 2003

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

Search the Archive

Re: Count pattern

  • To: mathgroup at smc.vnet.net
  • Subject: [mg41319] Re: Count pattern
  • From: "Peltio" <peltio at twilight.zone>
  • Date: Wed, 14 May 2003 08:17:01 -0400 (EDT)
  • References: <b9qabm$htm$1@smc.vnet.net>
  • Reply-to: "Peltio" <peltioNOSP at Miname.com.invalid>
  • Sender: owner-wri-mathgroup at wolfram.com

"Søren Merser" wrote

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

In three lines:
    upSelect[lst_List,th_]:=Select[lst,# >= th &]
    MupCount[lst_List,th_List]:=Map[Length[upSelect[lst,#]]&,th]
    MupCount[s,t]

In two lines:
    upSelect[lst_List,th_]:=Select[lst,# >= th &]
    Length[upSelect[s,#]]&/@t

In one line:
    Function[th, Length[Select[s, # >= th &]]][#] & /@ t

cheers,
Peltio, now heading for a Danish beer... : )
- invalid address in reply-to. Crafty demunging needed to mail me.




  • Prev by Date: Re: Count pattern
  • Next by Date: Re: Count pattern
  • Previous by thread: Re: Count pattern
  • Next by thread: Re: Count pattern