Defining in(a,b)

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])?

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
2 Likes

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

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.

1 Like