Defining in(a,b)


#1

Is in(a,b) defined automatically by making b iterable and defining ==(a1::T, a2::T) where T is typeof(a) and typeof(b[i])?


#2

in is defined as in(x, itr) = any(y -> y == x, itr)

any is defined as

function any(f, itr)
    for x in itr
        f(x) && return true
    end
    return false
end

#3

I think it would be handy if a dependency tree of all these Base functions often overloaded was documented.


#4

Perhaps, the documentation is pretty good here though imo:

Determine whether an item is in the given collection, in the sense that it
is == to one of the values generated by iterating over the collection.