diff --git a/NEWS.md b/NEWS.md index 5c514027923d82..506da90486aea8 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,9 @@ Julia v0.5.0 Release Notes New language features --------------------- + * `x ∈ X` is now a synonym for `x in X` in `for` loops and comprehensions, + as it already was in comparisons ([#13824]). + Language changes ---------------- @@ -1569,6 +1572,7 @@ Too numerous to mention. [#7917]: https://github.com/JuliaLang/julia/issues/7917 [#7992]: https://github.com/JuliaLang/julia/issues/7992 [#8011]: https://github.com/JuliaLang/julia/issues/8011 +[#8036]: https://github.com/JuliaLang/julia/issues/8036 [#8089]: https://github.com/JuliaLang/julia/issues/8089 [#8113]: https://github.com/JuliaLang/julia/issues/8113 [#8135]: https://github.com/JuliaLang/julia/issues/8135 @@ -1712,6 +1716,11 @@ Too numerous to mention. [#13062]: https://github.com/JuliaLang/julia/issues/13062 [#13338]: https://github.com/JuliaLang/julia/issues/13338 [#13387]: https://github.com/JuliaLang/julia/issues/13387 +[#13440]: https://github.com/JuliaLang/julia/issues/13440 [#13465]: https://github.com/JuliaLang/julia/issues/13465 [#13480]: https://github.com/JuliaLang/julia/issues/13480 +[#13496]: https://github.com/JuliaLang/julia/issues/13496 [#13542]: https://github.com/JuliaLang/julia/issues/13542 +[#13680]: https://github.com/JuliaLang/julia/issues/13680 +[#13681]: https://github.com/JuliaLang/julia/issues/13681 +[#13824]: https://github.com/JuliaLang/julia/issues/13824 diff --git a/doc/manual/control-flow.rst b/doc/manual/control-flow.rst index 143f0de971bf74..b2a4de4279b1ec 100644 --- a/doc/manual/control-flow.rst +++ b/doc/manual/control-flow.rst @@ -483,8 +483,8 @@ See :ref:`man-variables-and-scoping` for a detailed explanation of variable scope and how it works in Julia. In general, the ``for`` loop construct can iterate over any container. -In these cases, the alternative (but fully equivalent) keyword ``in`` is -typically used instead of ``=``, since it makes the code read more +In these cases, the alternative (but fully equivalent) keyword ``in`` +or `∈` is typically used instead of ``=``, since it makes the code read more clearly: .. doctest:: @@ -496,7 +496,7 @@ clearly: 4 0 - julia> for s in ["foo","bar","baz"] + julia> for s ∈ ["foo","bar","baz"] println(s) end foo diff --git a/src/julia-parser.scm b/src/julia-parser.scm index 543233921d834c..45ba68d602c322 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -1413,7 +1413,8 @@ r) ((eq? r ':) r) - ((and (length= r 4) (eq? (car r) 'comparison) (eq? (caddr r) 'in)) + ((and (length= r 4) (eq? (car r) 'comparison) + (or (eq? (caddr r) 'in) (eq? (caddr r) '∈))) `(= ,(cadr r) ,(cadddr r))) (else (error "invalid iteration specification"))))) diff --git a/test/core.jl b/test/core.jl index 6755bc6a775ff9..11acd4018c3b6d 100644 --- a/test/core.jl +++ b/test/core.jl @@ -3473,3 +3473,12 @@ f11327{T}(::Type{T},x::T) = x let T=TypeVar(:T,true) @test typeintersect(Tuple{Type{T},T}, Tuple{Type{Type{Float64}},Type{Int}}) === Union{} end + +# issue #8487 +@test [x for x in 1:3] == [x for x ∈ 1:3] == [x for x ∈ 1:3] +let A = Array(Int, 4,3) + for i ∈ 1:size(A,1), j ∈ 1:size(A,2) + A[i,j] = 17*i + 51*j + end + @test A == [17*i + 51*j for i ∈ 1:size(A,1), j ∈ 1:size(A,2)] +end