The indexin
function does something similar to what you want:
indexin(a, b)
Returns a vector containing the highest index in
b
for each value ina
that is a member ofb
. The output vector contains 0 wherevera
is not a member ofb
.
Since you want a boolean for each element in your giant_list
(instead of the index in good_letters
), you can simply do:
julia> indexin(giant_list, good_letters) .> 0
3-element BitArray{1}:
true
false
false
The implementation of indexin
is very straightforward, and points the way to how you might optimize this if you don’t care about the indices in b
:
function vectorin(a, b)
bset = Set(b)
[i in bset for i in a]
end
Only a limited set of names may be used as infix operators, so it’s not possible to use it as an infix operator.