Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Finding Position in an ordered list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg57737] Re: Finding Position in an ordered list
  • From: dh <dh at metrohm.ch>
  • Date: Tue, 7 Jun 2005 02:03:38 -0400 (EDT)
  • References: <d811k4$cch$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Janos,
I think "DiscreteMath`Combinatorica`BinarySearch" is what you are 
searching for.

?BinarySearch

BinarySearch[l, k] searches sorted list l for key k and gives the 
position of l containing k, if k is present in l. Otherwise, if k is 
absent in l, the function returns (p + 1/2) where k falls between the 
elements of l in positions p and p+1. BinarySearch[l, k, f] gives the 
position of k in the list obtained from l by applying f to each element 
in l.

sincerely, Daniel

janostothmeister at gmail.com wrote:
> I wonder if it is possible to use the knowledge
> that a list in which I am looking for the position
> of an element is ordered. I want a quicker solution then e.g.
> lis={ac,dmk,rfg,sty,zxxer}
> Position[lis,sty]
> 
> I am certainly interested in longer lists...
> 
> Thank you,
> 
> Janos
> 
> 


  • Prev by Date: Re: Finding Position in an ordered list
  • Next by Date: Re: Quadratic Form Contours
  • Previous by thread: Re: Finding Position in an ordered list
  • Next by thread: Re: Finding Position in an ordered list