Skip to content

joshday/SearchSortedNearest.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build status

SearchSortedNearest

This package provides a single function:

searchsortednearest(a, x; by=<transform>, lt=<comparison>, distance=(a,b)->abs(a-b), rev=false)

Find the index of (sorted) collection a that has the smallest distance to x.
Ties go to the smallest index.

Examples

using SearchSortedNearest

searchsortednearest(1:10, 1.1) == 1
searchsortednearest(1:10, 1.9) == 2

Attribution

This implementation is based on code provided by @traktofon on the Julia Discourse.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages