MathGroup Archive 1998

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

Search the Archive

Re:Select xs.t.y>10

  • To: mathgroup at smc.vnet.net
  • Subject: [mg13992] Re:Select xs.t.y>10
  • From: Allan Hayes <hay at haystack.demon.co.uk>
  • Date: Sat, 12 Sep 1998 16:59:16 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

Jason Gill wrote:
> 
> I came across what seems like it should be a simple little function, but
> could not come up with a clever way to implement it.  Generally, what I
> am trying to do is take a list of lists of length 2 ie a list of x,y
> coordinates, and Select x values based on some criterion for y.  For
> example I want to select the first x value for which the corresponding
> y is greater than 5.
> I can write a function using Position and Take etc. , but there must be
> a clever,and more efficient way to do this.  Any thoughts... Jason

Jason:

data= {{1,2},{2,6},{3,6}};

Cases[data,{x_,y_}/;y>5->x, {1},1]

{2}

Allan
-- 
Allan Hayes
Training and Consulting
Leicester, UK
hay at haystack.demon.co.uk
http://www.haystack.demon.co.uk
voice: +44 (0)116 271 4198
fax: +44 (0)116 271 8642



  • Prev by Date: Re: NO HELP FOR NOTATIONS PACKAGE
  • Next by Date: Re: Q: efficient list operation wanted
  • Previous by thread: Two column style-sheet
  • Next by thread: Re: list referencing with [[]][[]]