Should "1 ∈ 1" be "true"?

I know it’s a trivial proposal, but, should a primitive type data object belong to(∈, in) itself? Axiom of regularity implicates that “No set is an element of itself”.

Hmm, technically, 1 isn’t a set, so 1 isn’t an element of 1 it’s element of {1} though.

5 Likes

The docs for in say

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.

In Julia, numbers are iterable:

julia> collect(1)
0-dimensional Array{Int64,0}:
1

and so 1 in 1 is true.

2 Likes

Numbers being iterable collections containing themselves is a quirk (wart, depending on your POV) in Julia. See the lengthy discussions in

https://github.com/JuliaLang/julia/issues/11769

https://github.com/JuliaLang/julia/issues/7903

https://github.com/JuliaLang/julia/pull/19700

I understand why this was not addressed for 1.0, and now it would be breaking, but I hope this is revisited at some point for 2.0.

8 Likes