Re: In which interval?
- To: mathgroup at smc.vnet.net
- Subject: [mg13361] Re: In which interval?
- From: "Allan Hayes" <hay at haystack.demon.cc.uk>
- Date: Mon, 20 Jul 1998 02:50:14 -0400
- References: <6oklgc$1nq@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Pal Lillevold wrote in message <6oklgc$1nq at smc.vnet.net>... >I need to resolve the following problem: > >Given N distinct real Intervals (x(i),x(i+1)); i=1,,,,N and a real >number R - in which interval is R located. In other words to identify >the unique value of i such that x(i)<=R<x(i+1). This is easy to do by >straight forward checking which value of the N i's which match the >inequalities. But this is very time-consuming when the number N is >large. Has anyone been confronted with this problem and resolved it >efficiently? I would highly appreciate any assistance. > >Thank you in advance and best regards. > >Pal Lillevold > Pal, pts = {1,2,4,6,10}; pts[[Flatten[{#-1,#}]&[Position[pts, x_/;(3<x),{1},1, Heads->False]]]] {2,4} ------------------------------------------------------------- Allan Hayes Training and Consulting Leicester UK http://www.haystack.demon.co.uk hay at haystack.demon.co.uk voice: +44 (0)116 271 4198 fax: +44(0)116 271 8642