Spyke
floorjamreply
lemmy.world

I first did something with findfirst, which needed some bounds checks. Then I saw another answer and they used searchsortedfirst which is just it ... Even the documentation reads like the problem description

3
verstrareply
programming.dev

Ah so the library is just made for problems like this. Who would have thought :)

1
MatFireply
lemmy.thias.xyz

Naahh… searchsortedfirst is simply faster than other search algorithms (in this specific case). Extremely useful in many applications.It ist there because Julia cares about efficiency

2

This helped me realize how much this aligns with my problems (and I guess the spirit of this test problem). Sometimes you have special knowledge of your data and can use much more efficient functions that are just there in Julia.

1

You reached the end

Sometimes Julia feels like cheating | Spyke