Julia: Deprecate findin(a, b) in favor or find(occursin(b), a)

Created on 7 Dec 2017  ·  8Comments  ·  Source: JuliaLang/julia

As part of the unification of search and find functions (https://github.com/JuliaLang/julia/issues/10593), we should deprecate findin(a, b) in favor of the more explicit find(occursin(b), a), which is equivalent to find(x -> x in b, a). occursin is already implemented in https://github.com/JuliaLang/julia/pull/24673.

deprecation search & find

Most helpful comment

Actually, something like occursin is needed so that we can dispatch to more efficient methods than the default linear search. We can't do that with custom anonymous functions.

I've added a commit replacing findin(a, b) with find(occursin(b), a) to https://github.com/JuliaLang/julia/pull/24673.

All 8 comments

oh man occursin is hard to parse for me, I just naturally break occur_sin visually. Bases hatred of underscores can be rough. The logic of this on the other hand is super sweet.

We could have a single-argument in(v) that does what occursin(v) does – it reads naturally, and I'm not sure what else it could possibly mean. It's slightly strange to do reverse currying, but 🤷‍♂️

We could have a single-argument in(v)

:100: It seems very natural to me, and FWIW, I introduced _in to do just that in a PR

That's tempting, but I'd rather have a general plan regarding currying functions, as it could be really confusing to have that (reverse) currying function if we don't do that more systematically. For example, we now have equalto(x), which could be replaced with ==(x) in the same vein.

@stevengj also proposed find(_ in c, x), pointing at https://github.com/JuliaLang/julia/issues/5571.

See #24990 for an implementation of find(_ in c, x) etcetera.

Actually, something like occursin is needed so that we can dispatch to more efficient methods than the default linear search. We can't do that with custom anonymous functions.

I've added a commit replacing findin(a, b) with find(occursin(b), a) to https://github.com/JuliaLang/julia/pull/24673.

oh man occursin is hard to parse for me, I just naturally break occur_sin visually. Bases hatred of underscores can be rough. The logic of this on the other hand is super sweet.

Same here, every time I see this I too parse this as occur_sin . Is there perhaps a nicer synonym for such a function: occurs_in, occurin appearin locatedin inside (throwing some names out there)?

Fixed by #24673.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

StefanKarpinski picture StefanKarpinski  ·  3Comments

dpsanders picture dpsanders  ·  3Comments

tkoolen picture tkoolen  ·  3Comments

arshpreetsingh picture arshpreetsingh  ·  3Comments

ararslan picture ararslan  ·  3Comments