Sep-13-2019, 02:27 AM

i am not asking for anyone to code this for me. i'm just wanting to know if there might be an already existing tool out there to do this. otherwise i'll code it myself.

i have a big list of tuples. the first item in each tuple is a floating point number. the remaining items in each tuple are items with association to that first item. the list is sorted. there may be tuples with exactly the same first item, and the order of these does not matter.

i need a function that is given a floating point number and with that number, needs to find the tuple with the closest first item. if adjacent tuples are exactly the same, the function needs to return a list of all that have exactly identical first items that meet the requirement of being closest.

i might redo this all using decimal.Decimal type instead of float.

speed is not important. the lookup will be rarely done, maybe a few dozen times at boot-up and once every few hours thereafter. if it takes a couple seconds to run, no big deal. the list will be just a few thousand in length at most.

i've imagined a few ways to optimize this lookup. but this is not needed in this case. sequential is sufficient.

i have a big list of tuples. the first item in each tuple is a floating point number. the remaining items in each tuple are items with association to that first item. the list is sorted. there may be tuples with exactly the same first item, and the order of these does not matter.

i need a function that is given a floating point number and with that number, needs to find the tuple with the closest first item. if adjacent tuples are exactly the same, the function needs to return a list of all that have exactly identical first items that meet the requirement of being closest.

i might redo this all using decimal.Decimal type instead of float.

speed is not important. the lookup will be rarely done, maybe a few dozen times at boot-up and once every few hours thereafter. if it takes a couple seconds to run, no big deal. the list will be just a few thousand in length at most.

i've imagined a few ways to optimize this lookup. but this is not needed in this case. sequential is sufficient.

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.