in(x) is a convenient function generator to check whether other variables are contained in x (e.g. for filtering). I was looking for a generator of functions that do the opposite (check if other variables contain x), and I have found it in ∋ (escaped as \ni), but this function does not have a readable ascii alternative name.
Working with strings, there is occursin that generalizes the behavior of in (so that it works with substrings, not only with characters), and its reverse contains. I think that contains would be a suitable name for the opposite of in for other types. However, contains only works with strings and characters, if I’m not mistaken. Why is it that? Would it be a good idea to extend its behavior?
I agree that filter(contains(x), y) is more legible than filter(∋(x), y), but I also feel that y in x is much more legible than contains(x, y), so I don’t see much advantage in having a two argument version of what you are proposing.
A disadvantage of having such methods in Base is that one could argue that contains is not doing the same thing in the AbstractString version as in the collection version because one is looking for a sequence (or a match of a regular expression) whereas the other is looking for a single element. Coupled with the fact that this filter example is somewhat rare and that one can use ∋, this might explain avoiding implementing these methods, but maybe the reason is just that nobody ever submitted such a PR.
I don’t think there’s a better answer than “that’s the way it (currently) is” here. The names and operations here have slowly iterated and improved, and I don’t think there’s a blocker preventing this from continuing to find more optimal behaviors. There’s this open issue:
I expect contains could be a suitable arg-reverse of in and a PR to that end could be accepted. In the meantime, if you want an ascii version (without pretty syntax) you can look at what in(x) does:
julia> in(1:5)
(::Base.Fix2{typeof(in), UnitRange{Int64}}) (generic function with 1 method)
julia> ni3 = Base.Fix1(in, 3)
(::Base.Fix1{typeof(in), Int64}) (generic function with 1 method)
julia> ni3(1:5)
true
julia> ni3(6:10)
false
Most of the curried operators use Base.Fix2 to capture the function and second argument. There’s no pretty syntax for it, but we can use its twin Base.Fix1 to instead store the first argument like above.