No problem!
Also, for posterity, I'll point out that my recursive solution doesn't
quite work as-is -- it'll loop around eventually. To prevent that behavior,
you need another line:
function findocc(f, A, n)
n == 1 && return findfirst(f, A)
prev = findocc(f, A, n - 1)
prev == 0 ? 0 : findnext(f, A, prev + 1)
end
On Friday, July 17, 2015 at 10:24:06 AM UTC-4, Pontus Stenetorp wrote:
>
> On 17 July 2015 at 15:07, David Gold <[email protected] <javascript:>>
> wrote:
> >
> > If you don't care about short-circuiting after finding the nth
> occurrence
> > you could of course just do `find(f, A)[n]`.
>
> For my specific application, n should be fairly small so this is an
> excellent option. I must have overlooked it in the documentation
> somehow, thank you!
>
> Pontus
>