Skip to content

SarThak191119/SearchSortedNearest.jl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 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

Releases

No releases published

Packages

No packages published

Languages

  • Julia 100.0%