Re: [julia-users] find element in sorted list

2015-11-07 Thread Michele Zaffalon
On Sat, Nov 7, 2015 at 4:34 PM, Milan Bouchet-Valat wrote: > Le samedi 07 novembre 2015 à 06:37 -0800, Michele Zaffalon a écrit : > > What is the best way of telling whether an element `x` is present in > > a sorted list `a`? > > > > Using `searchsortedlist`, I also need to check that the element

Re: [julia-users] find element in sorted list

2015-11-07 Thread Milan Bouchet-Valat
Le samedi 07 novembre 2015 à 06:37 -0800, Michele Zaffalon a écrit : > What is the best way of telling whether an element `x` is present in > a sorted list `a`? > > Using `searchsortedlist`, I also need to check that the element is > present in the list. This is what I do > > function isinsortedl

[julia-users] find element in sorted list

2015-11-07 Thread Michele Zaffalon
What is the best way of telling whether an element `x` is present in a sorted list `a`? Using `searchsortedlist`, I also need to check that the element is present in the list. This is what I do function isinsortedlist(a, x) n = searchsortedfirst(a, x) n <= length(a) && a[n] == x end Sh