From 062567193682ac5e10bad1865eb7ef736fdffb95 Mon Sep 17 00:00:00 2001 From: Jiahao Chen Date: Sat, 19 Apr 2014 09:30:01 -0400 Subject: [PATCH 01/19] =?UTF-8?q?Add=20=E2=8A=97=20as=20synonym=20for=20kr?= =?UTF-8?q?on?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/exports.jl | 1 + base/operators.jl | 2 ++ src/julia-parser.scm | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/base/exports.jl b/base/exports.jl index c862ebfda3323..393b975158c68 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -224,6 +224,7 @@ export |, ~, :, + ⊗, A_ldiv_B!, A_ldiv_Bc, A_ldiv_Bt, diff --git a/base/operators.jl b/base/operators.jl index f6674e9153873..c9f938267fbbd 100644 --- a/base/operators.jl +++ b/base/operators.jl @@ -110,6 +110,7 @@ fld{T<:Real}(x::T, y::T) = convert(T,round((x-mod(x,y))/y)) # operator alias const % = rem .%(x::Real, y::Real) = x%y +const ⊗ = kron # mod returns in [0,y) whereas mod1 returns in (0,y] mod1{T<:Real}(x::T, y::T) = y-mod(y-x,y) @@ -396,6 +397,7 @@ export |>, <|, ~, + ⊗, colon, hcat, vcat, diff --git a/src/julia-parser.scm b/src/julia-parser.scm index a87aa72ca0509..55c391c428ebc 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -12,7 +12,7 @@ (: |..|) (+ - |.+| |.-| |\|| $) (<< >> >>> |.<<| |.>>| |.>>>|) - (* / |./| % |.%| & |.*| |\\| |.\\|) + (* / |./| % |.%| & ⊗ |.*| |\\| |.\\|) (// .//) (^ |.^|) (|::|) From 2a26899811e896a15b11127131ed3a064bca366e Mon Sep 17 00:00:00 2001 From: Jiahao Chen Date: Sat, 19 Apr 2014 09:36:58 -0400 Subject: [PATCH 02/19] =?UTF-8?q?Add=20=E2=88=9A=20as=20synonym=20for=20sq?= =?UTF-8?q?rt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/exports.jl | 1 + base/math.jl | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/base/exports.jl b/base/exports.jl index 393b975158c68..469c6991c56e7 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -440,6 +440,7 @@ export unsigned, widemul, zero, + √, # specfun airy, diff --git a/base/math.jl b/base/math.jl index b480ffbfbdcce..d9e79dcef2d50 100644 --- a/base/math.jl +++ b/base/math.jl @@ -16,7 +16,7 @@ export sin, cos, tan, sinh, cosh, tanh, asin, acos, atan, besselj0, besselj1, besselj, bessely0, bessely1, bessely, hankelh1, hankelh2, besseli, besselk, besselh, beta, lbeta, eta, zeta, polygamma, invdigamma, digamma, trigamma, - erfinv, erfcinv + erfinv, erfcinv, √ import Base: log, exp, sin, cos, tan, sinh, cosh, tanh, asin, acos, atan, asinh, acosh, atanh, sqrt, log2, log10, @@ -279,6 +279,7 @@ sqrt(x::Float64) = box(Float64,sqrt_llvm(unbox(Float64,x))) sqrt(x::Float32) = box(Float32,sqrt_llvm(unbox(Float32,x))) sqrt(x::Real) = sqrt(float(x)) @vectorize_1arg Number sqrt +const √=sqrt for f in (:ceil, :trunc, :significand) # :rint, :nearbyint @eval begin From fae924a6ea0cfc7250131d2c58a094d788282c9c Mon Sep 17 00:00:00 2001 From: Jiahao Chen Date: Sat, 19 Apr 2014 10:09:42 -0400 Subject: [PATCH 03/19] =?UTF-8?q?Add=20obelus=20(=C3=B7)=20as=20synonym=20?= =?UTF-8?q?for=20div?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/exports.jl | 1 + base/operators.jl | 2 ++ src/julia-parser.scm | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/base/exports.jl b/base/exports.jl index 469c6991c56e7..8c920b7a3b55b 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -225,6 +225,7 @@ export ~, :, ⊗, + ÷, A_ldiv_B!, A_ldiv_Bc, A_ldiv_Bt, diff --git a/base/operators.jl b/base/operators.jl index c9f938267fbbd..bab1bc478ebbe 100644 --- a/base/operators.jl +++ b/base/operators.jl @@ -111,6 +111,7 @@ fld{T<:Real}(x::T, y::T) = convert(T,round((x-mod(x,y))/y)) const % = rem .%(x::Real, y::Real) = x%y const ⊗ = kron +const ÷ = div # mod returns in [0,y) whereas mod1 returns in (0,y] mod1{T<:Real}(x::T, y::T) = y-mod(y-x,y) @@ -398,6 +399,7 @@ export <|, ~, ⊗, + ÷, colon, hcat, vcat, diff --git a/src/julia-parser.scm b/src/julia-parser.scm index 55c391c428ebc..77bd7fbacea17 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -12,7 +12,7 @@ (: |..|) (+ - |.+| |.-| |\|| $) (<< >> >>> |.<<| |.>>| |.>>>|) - (* / |./| % |.%| & ⊗ |.*| |\\| |.\\|) + (* / |./| ÷ % |.%| & ⊗ |.*| |\\| |.\\|) (// .//) (^ |.^|) (|::|) From 67ce8b57ee21ac0fae1aafa05b80e021bb3e97c8 Mon Sep 17 00:00:00 2001 From: Jiahao Chen Date: Sat, 19 Apr 2014 10:31:18 -0400 Subject: [PATCH 04/19] =?UTF-8?q?Add=20=E2=88=85=20(empty=20set)=20as=20sy?= =?UTF-8?q?nonym=20for=20Set{Any}({})?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/exports.jl | 1 + base/set.jl | 1 + 2 files changed, 2 insertions(+) diff --git a/base/exports.jl b/base/exports.jl index 8c920b7a3b55b..9981f408326c9 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -108,6 +108,7 @@ export WeakRef, Woodbury, Zip, + ∅, # Ccall types Cchar, diff --git a/base/set.jl b/base/set.jl index ee3421c78924c..e600569594e3d 100644 --- a/base/set.jl +++ b/base/set.jl @@ -5,6 +5,7 @@ type Set{T} Set(itr) = union!(new(Dict{T,Nothing}()), itr) end Set() = Set{Any}() +∅ = Set() Set(itr) = Set{eltype(itr)}(itr) show(io::IO, s::Set) = (show(io, typeof(s)); show_comma_array(io, s,"({","})")) From 01d98fe87f40daff40900bc91857081deab98447 Mon Sep 17 00:00:00 2001 From: Jiahao Chen Date: Sat, 19 Apr 2014 10:52:35 -0400 Subject: [PATCH 05/19] =?UTF-8?q?Add=20=E2=88=88=20as=20synonym=20for=20`i?= =?UTF-8?q?n`=20and=20=E2=88=8B=20for=20containment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/exports.jl | 2 ++ base/reduce.jl | 2 ++ src/julia-parser.scm | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/base/exports.jl b/base/exports.jl index 9981f408326c9..0118fbc8923ee 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -747,6 +747,8 @@ export union, unique, values, + ∈, + ∋, # strings and text output ascii, diff --git a/base/reduce.jl b/base/reduce.jl index 66c6d1236bc04..05cffc4a64967 100644 --- a/base/reduce.jl +++ b/base/reduce.jl @@ -121,6 +121,8 @@ function in(x, itr) end return false end +const ∈ = in +∋(itr, x) = ∈(x, itr) function contains(itr, x) depwarn("contains(collection, item) is deprecated, use in(item, collection) instead", :contains) diff --git a/src/julia-parser.scm b/src/julia-parser.scm index 77bd7fbacea17..ed967cf2c8c1b 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -7,7 +7,7 @@ ; the way the lexer works, every prefix of an operator must also ; be an operator. (-- -->) - (> < >= <= == === != !== |.>| |.<| |.>=| |.<=| |.==| |.!=| |.=| |.!| |<:| |>:|) + (> < >= <= == === != !== |.>| |.<| |.>=| |.<=| |.==| |.!=| |.=| |.!| |<:| |>:| ∈ ∋) (|\|>| |<\||) (: |..|) (+ - |.+| |.-| |\|| $) From edf4e3d598f3b60f106ca1edf7f38b0ce9f2cd72 Mon Sep 17 00:00:00 2001 From: Jiahao Chen Date: Sat, 19 Apr 2014 10:57:38 -0400 Subject: [PATCH 06/19] =?UTF-8?q?Add=20=E2=8B=85=20as=20synonym=20for=20`d?= =?UTF-8?q?ot`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/exports.jl | 1 + base/linalg.jl | 1 + base/linalg/matmul.jl | 1 + src/julia-parser.scm | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/base/exports.jl b/base/exports.jl index 0118fbc8923ee..901f2fdd6012f 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -661,6 +661,7 @@ export triu!, triu, vecnorm, + ⋅, # sparse etree, diff --git a/base/linalg.jl b/base/linalg.jl index 7abb721544057..221adc3e535c7 100644 --- a/base/linalg.jl +++ b/base/linalg.jl @@ -115,6 +115,7 @@ export tril!, triu!, vecnorm, + ⋅, # Operators \, diff --git a/base/linalg/matmul.jl b/base/linalg/matmul.jl index e8f9da37c20ec..60ef6de6a8f38 100644 --- a/base/linalg/matmul.jl +++ b/base/linalg/matmul.jl @@ -58,6 +58,7 @@ function dot(x::AbstractVector, y::AbstractVector) s end dot(x::Number, y::Number) = conj(x) * y +const ⋅ = dot Ac_mul_B(x::Vector, y::Vector) = [dot(x, y)] At_mul_B{T<:Real}(x::Vector{T}, y::Vector{T}) = [dot(x, y)] At_mul_B{T<:BlasComplex}(x::Vector{T}, y::Vector{T}) = [BLAS.dotu(x, y)] diff --git a/src/julia-parser.scm b/src/julia-parser.scm index ed967cf2c8c1b..1f5e1d9f1f268 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -12,7 +12,7 @@ (: |..|) (+ - |.+| |.-| |\|| $) (<< >> >>> |.<<| |.>>| |.>>>|) - (* / |./| ÷ % |.%| & ⊗ |.*| |\\| |.\\|) + (* / |./| ÷ % ⋅ |.%| & ⊗ |.*| |\\| |.\\|) (// .//) (^ |.^|) (|::|) From 73693262ada674fc7b1697ebcef3cb3d3e525ecd Mon Sep 17 00:00:00 2001 From: Jiahao Chen Date: Sat, 19 Apr 2014 11:01:15 -0400 Subject: [PATCH 07/19] =?UTF-8?q?Add=20=E2=8A=86=20as=20synonym=20for=20`i?= =?UTF-8?q?ssubset`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/exports.jl | 1 + base/set.jl | 1 + src/julia-parser.scm | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/base/exports.jl b/base/exports.jl index 901f2fdd6012f..10eabc7de24e2 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -750,6 +750,7 @@ export values, ∈, ∋, + ⊆, # strings and text output ascii, diff --git a/base/set.jl b/base/set.jl index e600569594e3d..7bcfff8098bee 100644 --- a/base/set.jl +++ b/base/set.jl @@ -86,6 +86,7 @@ function issubset(l, r) end return true end +const ⊆ = issubset function unique(C) out = Array(eltype(C),0) diff --git a/src/julia-parser.scm b/src/julia-parser.scm index 1f5e1d9f1f268..ea9533c77f9bd 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -7,7 +7,7 @@ ; the way the lexer works, every prefix of an operator must also ; be an operator. (-- -->) - (> < >= <= == === != !== |.>| |.<| |.>=| |.<=| |.==| |.!=| |.=| |.!| |<:| |>:| ∈ ∋) + (> < >= <= == === != !== |.>| |.<| |.>=| |.<=| |.==| |.!=| |.=| |.!| |<:| |>:| ∈ ∋ ⊆) (|\|>| |<\||) (: |..|) (+ - |.+| |.-| |\|| $) From ad12241cc672b1308cfd3c6f06e365c3ee693906 Mon Sep 17 00:00:00 2001 From: Jiahao Chen Date: Sat, 19 Apr 2014 11:09:08 -0400 Subject: [PATCH 08/19] =?UTF-8?q?More=20set=20relations=20=E2=8A=88,=20?= =?UTF-8?q?=E2=8A=82,=20=E2=8A=84,=20=E2=8A=8A.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Strict subsets ⊂, ⊊ - Negated synonyms ⊈, ⊄ --- base/exports.jl | 4 ++++ base/set.jl | 4 ++++ src/julia-parser.scm | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/base/exports.jl b/base/exports.jl index 10eabc7de24e2..58cc6a49ac356 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -751,6 +751,10 @@ export ∈, ∋, ⊆, + ⊈, + ⊂, + ⊄, + ⊊, # strings and text output ascii, diff --git a/base/set.jl b/base/set.jl index 7bcfff8098bee..f3b293cee698b 100644 --- a/base/set.jl +++ b/base/set.jl @@ -87,6 +87,10 @@ function issubset(l, r) return true end const ⊆ = issubset +⊂(l::Set, r::Set) = ⊆(l, r) && l!=r +const ⊊ = ⊂ +⊈(l::Set, r::Set) = !⊆(l, r) +⊄(l::Set, r::Set) = !⊂(l, r) function unique(C) out = Array(eltype(C),0) diff --git a/src/julia-parser.scm b/src/julia-parser.scm index ea9533c77f9bd..8e2683d213573 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -7,7 +7,7 @@ ; the way the lexer works, every prefix of an operator must also ; be an operator. (-- -->) - (> < >= <= == === != !== |.>| |.<| |.>=| |.<=| |.==| |.!=| |.=| |.!| |<:| |>:| ∈ ∋ ⊆) + (> < >= <= == === != !== |.>| |.<| |.>=| |.<=| |.==| |.!=| |.=| |.!| |<:| |>:| ∈ ∋ ⊆ ⊈ ⊂ ⊄ ⊊) (|\|>| |<\||) (: |..|) (+ - |.+| |.-| |\|| $) From e81e2bb895342e3cb4688fad4a1c9ef4f3c905d3 Mon Sep 17 00:00:00 2001 From: Jiahao Chen Date: Sat, 19 Apr 2014 11:19:31 -0400 Subject: [PATCH 09/19] =?UTF-8?q?Add=20=E2=88=A9=20and=20=E2=88=AA=20as=20?= =?UTF-8?q?synonyms=20for=20`intersect`=20and=20`union`=20resp.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/exports.jl | 2 ++ base/set.jl | 2 ++ src/julia-parser.scm | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/base/exports.jl b/base/exports.jl index 58cc6a49ac356..63933d1b25fc7 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -755,6 +755,8 @@ export ⊂, ⊄, ⊊, + ∩, + ∪, # strings and text output ascii, diff --git a/base/set.jl b/base/set.jl index f3b293cee698b..346230087b09f 100644 --- a/base/set.jl +++ b/base/set.jl @@ -51,6 +51,7 @@ function union(s::Set, sets::Set...) end return u end +const ∪ = union intersect(s::Set) = copy(s) function intersect(s::Set, sets::Set...) @@ -65,6 +66,7 @@ function intersect(s::Set, sets::Set...) end return i end +const ∩ = intersect function setdiff(a::Set, b::Set) d = copy(a) diff --git a/src/julia-parser.scm b/src/julia-parser.scm index 8e2683d213573..56bc3c7d3f932 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -10,7 +10,7 @@ (> < >= <= == === != !== |.>| |.<| |.>=| |.<=| |.==| |.!=| |.=| |.!| |<:| |>:| ∈ ∋ ⊆ ⊈ ⊂ ⊄ ⊊) (|\|>| |<\||) (: |..|) - (+ - |.+| |.-| |\|| $) + (+ - |.+| |.-| |\|| $ ∩ ∪) (<< >> >>> |.<<| |.>>| |.>>>|) (* / |./| ÷ % ⋅ |.%| & ⊗ |.*| |\\| |.\\|) (// .//) From 73f65edc09e0b16ca1be576c295e8cebbf947556 Mon Sep 17 00:00:00 2001 From: Jiahao Chen Date: Sat, 19 Apr 2014 11:25:29 -0400 Subject: [PATCH 10/19] =?UTF-8?q?Add=20=E2=96=B3=20as=20synonym=20for=20`s?= =?UTF-8?q?ymdiff`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/array.jl | 1 + base/exports.jl | 1 + src/julia-parser.scm | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/base/array.jl b/base/array.jl index 471158774d4b2..114a26885dc25 100644 --- a/base/array.jl +++ b/base/array.jl @@ -1337,6 +1337,7 @@ end symdiff(a) = a symdiff(a, b) = union(setdiff(a,b), setdiff(b,a)) symdiff(a, b, rest...) = symdiff(a, symdiff(b, rest...)) +const △ = symdiff _cumsum_type{T<:Number}(v::AbstractArray{T}) = typeof(+zero(T)) _cumsum_type(v) = typeof(v[1]+v[1]) diff --git a/base/exports.jl b/base/exports.jl index 63933d1b25fc7..39e96d3e9bdd4 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -757,6 +757,7 @@ export ⊊, ∩, ∪, + △, # strings and text output ascii, diff --git a/src/julia-parser.scm b/src/julia-parser.scm index 56bc3c7d3f932..81044135540df 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -10,7 +10,7 @@ (> < >= <= == === != !== |.>| |.<| |.>=| |.<=| |.==| |.!=| |.=| |.!| |<:| |>:| ∈ ∋ ⊆ ⊈ ⊂ ⊄ ⊊) (|\|>| |<\||) (: |..|) - (+ - |.+| |.-| |\|| $ ∩ ∪) + (+ - |.+| |.-| |\|| $ ∩ ∪ △) (<< >> >>> |.<<| |.>>| |.>>>|) (* / |./| ÷ % ⋅ |.%| & ⊗ |.*| |\\| |.\\|) (// .//) From 6036e782921d4e320f897a4d82eb4142a0c9fd87 Mon Sep 17 00:00:00 2001 From: Jiahao Chen Date: Sat, 19 Apr 2014 11:30:16 -0400 Subject: [PATCH 11/19] =?UTF-8?q?Add=20negated=20element=20containments=20?= =?UTF-8?q?=E2=88=89,=20=E2=88=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/exports.jl | 2 ++ base/reduce.jl | 4 +++- src/julia-parser.scm | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/base/exports.jl b/base/exports.jl index 39e96d3e9bdd4..762ffaba2db40 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -749,7 +749,9 @@ export unique, values, ∈, + ∉, ∋, + ∌, ⊆, ⊈, ⊂, diff --git a/base/reduce.jl b/base/reduce.jl index 05cffc4a64967..edfad14e1dc2d 100644 --- a/base/reduce.jl +++ b/base/reduce.jl @@ -122,7 +122,9 @@ function in(x, itr) return false end const ∈ = in -∋(itr, x) = ∈(x, itr) +∉(x, itr)=!∈(x, itr) +∋(itr, x)= ∈(x, itr) +∌(itr, x)=!∋(itr, x) function contains(itr, x) depwarn("contains(collection, item) is deprecated, use in(item, collection) instead", :contains) diff --git a/src/julia-parser.scm b/src/julia-parser.scm index 81044135540df..4f083577a8aee 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -7,7 +7,7 @@ ; the way the lexer works, every prefix of an operator must also ; be an operator. (-- -->) - (> < >= <= == === != !== |.>| |.<| |.>=| |.<=| |.==| |.!=| |.=| |.!| |<:| |>:| ∈ ∋ ⊆ ⊈ ⊂ ⊄ ⊊) + (> < >= <= == === != !== |.>| |.<| |.>=| |.<=| |.==| |.!=| |.=| |.!| |<:| |>:| ∈ ∉ ∋ ∌ ⊆ ⊈ ⊂ ⊄ ⊊) (|\|>| |<\||) (: |..|) (+ - |.+| |.-| |\|| $ ∩ ∪ △) From 672ca6e52488c6050de26c3de480d2784380c7cc Mon Sep 17 00:00:00 2001 From: Jiahao Chen Date: Sat, 19 Apr 2014 11:51:31 -0400 Subject: [PATCH 12/19] =?UTF-8?q?More=20comparsion=20operators=20=E2=89=A0?= =?UTF-8?q?=20(!=3D),=20=E2=89=A1=20(=3D=3D=3D),=20=E2=89=A2=20(!=3D=3D),?= =?UTF-8?q?=20=E2=89=A4=20(<=3D),=20=E2=89=A5=20(>=3D),=20.=E2=89=A5=20(.>?= =?UTF-8?q?=3D),=20.=E2=89=A4=20(<=3D),=20.=E2=89=A0=20(.!=3D)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/exports.jl | 8 ++++++++ base/operators.jl | 9 ++++++++- src/julia-parser.scm | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/base/exports.jl b/base/exports.jl index 762ffaba2db40..899678e37be45 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -188,7 +188,10 @@ export # Operators !, !=, + ≠, !==, + ≡, + ≢, $, %, &, @@ -196,15 +199,18 @@ export +, -, .!=, + .≠, .+, .-, .*, ./, .<, .<=, + .≤, .==, .>, .>=, + .≥, .\, .^, /, @@ -213,9 +219,11 @@ export <:, <<, <=, + ≤, ==, >, >=, + ≥, >>, #.>>, #.<<, diff --git a/base/operators.jl b/base/operators.jl index bab1bc478ebbe..8e58a1b18b0af 100644 --- a/base/operators.jl +++ b/base/operators.jl @@ -13,14 +13,19 @@ isequal(T::Type, S::Type) = typeseq(T, S) isequal(x,y) = is(x,y) ==(x,y) = isequal(x,y) !=(x,y) = !(x==y) +const ≠ = != +const ≡ = is !==(x,y) = !is(x,y) - +const ≢ = !== < (x,y) = isless(x,y) > (x,y) = y < x <=(x,y) = !(y < x) +const ≤ = <= >=(x,y) = (y <= x) +const ≥ = >= .> (x,y) = y.=(x,y) = y.<=x +const .≥ = .>= # this definition allows Number types to implement < instead of isless, # which is more idiomatic: @@ -90,6 +95,8 @@ end .!=(x::Number,y::Number) = x!=y .< (x::Real,y::Real) = x> and >>> takes Int32 as second arg <<(x,y::Integer) = x << convert(Int32,y) diff --git a/src/julia-parser.scm b/src/julia-parser.scm index 4f083577a8aee..c9b441a8c24cf 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -7,7 +7,7 @@ ; the way the lexer works, every prefix of an operator must also ; be an operator. (-- -->) - (> < >= <= == === != !== |.>| |.<| |.>=| |.<=| |.==| |.!=| |.=| |.!| |<:| |>:| ∈ ∉ ∋ ∌ ⊆ ⊈ ⊂ ⊄ ⊊) + (> < >= ≥ <= ≤ == === ≡ != ≠ !== ≢ |.>| |.<| |.>=| |.≥| |.<=| |.≤| |.==| |.!=| |.≠| |.=| |.!| |<:| |>:| ∈ ∉ ∋ ∌ ⊆ ⊈ ⊂ ⊄ ⊊) (|\|>| |<\||) (: |..|) (+ - |.+| |.-| |\|| $ ∩ ∪ △) From 915ba49e2734f7eb2c33b74fef827ad55abb38ff Mon Sep 17 00:00:00 2001 From: Jiahao Chen Date: Sat, 19 Apr 2014 12:19:23 -0400 Subject: [PATCH 13/19] =?UTF-8?q?Add=20double=20solidus=20(=E2=AB=BD)=20as?= =?UTF-8?q?=20synonym=20for=20rational=20division=20(//)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Is (.//) defined anywhere? --- base/exports.jl | 1 + base/rational.jl | 1 + src/julia-parser.scm | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/base/exports.jl b/base/exports.jl index 899678e37be45..ec1ec93459048 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -215,6 +215,7 @@ export .^, /, //, + ⫽, <, <:, <<, diff --git a/base/rational.jl b/base/rational.jl index 2c22105a99465..4c30ae057c905 100644 --- a/base/rational.jl +++ b/base/rational.jl @@ -26,6 +26,7 @@ function //(x::Complex, y::Complex) yy = real(y*y') complex(real(xy)//yy, imag(xy)//yy) end +const ⫽ = // function show(io::IO, x::Rational) if isinf(x) diff --git a/src/julia-parser.scm b/src/julia-parser.scm index c9b441a8c24cf..1b857542e07f0 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -13,7 +13,7 @@ (+ - |.+| |.-| |\|| $ ∩ ∪ △) (<< >> >>> |.<<| |.>>| |.>>>|) (* / |./| ÷ % ⋅ |.%| & ⊗ |.*| |\\| |.\\|) - (// .//) + (// .// ⫽) (^ |.^|) (|::|) (|.|))) From efcc36b0e524ebf8bce504bdb926a3fea7fc8c28 Mon Sep 17 00:00:00 2001 From: Jiahao Chen Date: Sat, 19 Apr 2014 12:36:16 -0400 Subject: [PATCH 14/19] =?UTF-8?q?Adds=20=E2=88=A3=20(divides)=20and=20its?= =?UTF-8?q?=20negation=20=E2=88=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/exports.jl | 2 ++ base/operators.jl | 2 ++ src/julia-parser.scm | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/base/exports.jl b/base/exports.jl index ec1ec93459048..b53c167ae1ac4 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -236,6 +236,8 @@ export :, ⊗, ÷, + ∣, + ∤, A_ldiv_B!, A_ldiv_Bc, A_ldiv_Bt, diff --git a/base/operators.jl b/base/operators.jl index 8e58a1b18b0af..d2e68e15bca3f 100644 --- a/base/operators.jl +++ b/base/operators.jl @@ -119,6 +119,8 @@ const % = rem .%(x::Real, y::Real) = x%y const ⊗ = kron const ÷ = div +∣(x::Real, y::Real) = y%x==0 #x∣y = x divides y +∤(x::Real, y::Real) = !∣(x,y) # mod returns in [0,y) whereas mod1 returns in (0,y] mod1{T<:Real}(x::T, y::T) = y-mod(y-x,y) diff --git a/src/julia-parser.scm b/src/julia-parser.scm index 1b857542e07f0..1235e707ade36 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -12,7 +12,7 @@ (: |..|) (+ - |.+| |.-| |\|| $ ∩ ∪ △) (<< >> >>> |.<<| |.>>| |.>>>|) - (* / |./| ÷ % ⋅ |.%| & ⊗ |.*| |\\| |.\\|) + (* / |./| ÷ ∣ ∤ % ⋅ |.%| & ⊗ |.*| |\\| |.\\|) (// .// ⫽) (^ |.^|) (|::|) From 971756a45490e305fbb234615275e92d8e5235b4 Mon Sep 17 00:00:00 2001 From: Jiahao Chen Date: Sat, 19 Apr 2014 12:47:59 -0400 Subject: [PATCH 15/19] =?UTF-8?q?Add=20=C3=97=20(cross=20product)=20as=20s?= =?UTF-8?q?ynonym=20for=20`cross`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/exports.jl | 1 + base/linalg.jl | 1 + base/linalg/generic.jl | 1 + src/julia-parser.scm | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/base/exports.jl b/base/exports.jl index b53c167ae1ac4..afab8983beed6 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -673,6 +673,7 @@ export triu, vecnorm, ⋅, + ×, # sparse etree, diff --git a/base/linalg.jl b/base/linalg.jl index 221adc3e535c7..47b18f27d64f6 100644 --- a/base/linalg.jl +++ b/base/linalg.jl @@ -116,6 +116,7 @@ export triu!, vecnorm, ⋅, + ×, # Operators \, diff --git a/base/linalg/generic.jl b/base/linalg/generic.jl index 8f8268bd2c9ac..c0221601458a2 100644 --- a/base/linalg/generic.jl +++ b/base/linalg/generic.jl @@ -20,6 +20,7 @@ end scale!(s::Number, X::AbstractArray) = scale!(X, s) cross(a::AbstractVector, b::AbstractVector) = [a[2]*b[3]-a[3]*b[2], a[3]*b[1]-a[1]*b[3], a[1]*b[2]-a[2]*b[1]] +const × = cross triu(M::AbstractMatrix) = triu(M,0) tril(M::AbstractMatrix) = tril(M,0) diff --git a/src/julia-parser.scm b/src/julia-parser.scm index 1235e707ade36..7e3609191856a 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -12,7 +12,7 @@ (: |..|) (+ - |.+| |.-| |\|| $ ∩ ∪ △) (<< >> >>> |.<<| |.>>| |.>>>|) - (* / |./| ÷ ∣ ∤ % ⋅ |.%| & ⊗ |.*| |\\| |.\\|) + (* / |./| ÷ ∣ ∤ % ⋅ × |.%| & ⊗ |.*| |\\| |.\\|) (// .// ⫽) (^ |.^|) (|::|) From 3cd38a517df2a9e678e00e8e50ca5447b81d6db2 Mon Sep 17 00:00:00 2001 From: Jiahao Chen Date: Sat, 19 Apr 2014 13:23:04 -0400 Subject: [PATCH 16/19] =?UTF-8?q?Remove=20=E2=88=85=20(empty=20set)=20and?= =?UTF-8?q?=20undefines=20=E2=8A=82=20and=20=E2=8A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ⊂ and ⊄ seem useful to have around for user-defined relations, but otoh it seems odd to define infix operators that are never used in Base. --- base/exports.jl | 1 - base/set.jl | 5 +---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/base/exports.jl b/base/exports.jl index afab8983beed6..e5635765702eb 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -108,7 +108,6 @@ export WeakRef, Woodbury, Zip, - ∅, # Ccall types Cchar, diff --git a/base/set.jl b/base/set.jl index 346230087b09f..297a31d007453 100644 --- a/base/set.jl +++ b/base/set.jl @@ -5,7 +5,6 @@ type Set{T} Set(itr) = union!(new(Dict{T,Nothing}()), itr) end Set() = Set{Any}() -∅ = Set() Set(itr) = Set{eltype(itr)}(itr) show(io::IO, s::Set) = (show(io, typeof(s)); show_comma_array(io, s,"({","})")) @@ -89,10 +88,8 @@ function issubset(l, r) return true end const ⊆ = issubset -⊂(l::Set, r::Set) = ⊆(l, r) && l!=r -const ⊊ = ⊂ +⊊(l::Set, r::Set) = ⊆(l, r) && l!=r ⊈(l::Set, r::Set) = !⊆(l, r) -⊄(l::Set, r::Set) = !⊂(l, r) function unique(C) out = Array(eltype(C),0) From 4a98190d66ed662df3111a5dcdfca1934976f9a2 Mon Sep 17 00:00:00 2001 From: Jiahao Chen Date: Tue, 22 Apr 2014 11:23:13 -0500 Subject: [PATCH 17/19] =?UTF-8?q?Changed=20operator=20precedence=20for=20?= =?UTF-8?q?=E2=88=A9=20and=20=E2=88=AA.=20Undefine=20=E2=96=B3.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/array.jl | 1 - src/julia-parser.scm | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/base/array.jl b/base/array.jl index 114a26885dc25..471158774d4b2 100644 --- a/base/array.jl +++ b/base/array.jl @@ -1337,7 +1337,6 @@ end symdiff(a) = a symdiff(a, b) = union(setdiff(a,b), setdiff(b,a)) symdiff(a, b, rest...) = symdiff(a, symdiff(b, rest...)) -const △ = symdiff _cumsum_type{T<:Number}(v::AbstractArray{T}) = typeof(+zero(T)) _cumsum_type(v) = typeof(v[1]+v[1]) diff --git a/src/julia-parser.scm b/src/julia-parser.scm index 7e3609191856a..462ce22263bed 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -10,9 +10,9 @@ (> < >= ≥ <= ≤ == === ≡ != ≠ !== ≢ |.>| |.<| |.>=| |.≥| |.<=| |.≤| |.==| |.!=| |.≠| |.=| |.!| |<:| |>:| ∈ ∉ ∋ ∌ ⊆ ⊈ ⊂ ⊄ ⊊) (|\|>| |<\||) (: |..|) - (+ - |.+| |.-| |\|| $ ∩ ∪ △) + (+ - |.+| |.-| |\|| ∪ $ △) (<< >> >>> |.<<| |.>>| |.>>>|) - (* / |./| ÷ ∣ ∤ % ⋅ × |.%| & ⊗ |.*| |\\| |.\\|) + (* / |./| ÷ ∣ ∤ % ⋅ × |.%| & ∩ ⊗ |.*| |\\| |.\\|) (// .// ⫽) (^ |.^|) (|::|) From a243cc679f7bea355fb7883801633404d936dff7 Mon Sep 17 00:00:00 2001 From: Jiahao Chen Date: Tue, 22 Apr 2014 11:32:01 -0500 Subject: [PATCH 18/19] =?UTF-8?q?Add=20=E2=88=A8=20and=20=E2=88=A7,=20and?= =?UTF-8?q?=20circled=20and=20boxed=20arithmetic=20operators?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ⊕ ⊖ ⊗ ⊘ ⊙ ⊚ ⊛ ⦸ ⦼ ⊞ ⊟ ⊠ ⊡ --- src/julia-parser.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/julia-parser.scm b/src/julia-parser.scm index 462ce22263bed..59cab060700c5 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -10,9 +10,9 @@ (> < >= ≥ <= ≤ == === ≡ != ≠ !== ≢ |.>| |.<| |.>=| |.≥| |.<=| |.≤| |.==| |.!=| |.≠| |.=| |.!| |<:| |>:| ∈ ∉ ∋ ∌ ⊆ ⊈ ⊂ ⊄ ⊊) (|\|>| |<\||) (: |..|) - (+ - |.+| |.-| |\|| ∪ $ △) + (+ - ⊕ ⊖ ⊞ ⊟ |.+| |.-| |\|| ∪ ∨ $ △) (<< >> >>> |.<<| |.>>| |.>>>|) - (* / |./| ÷ ∣ ∤ % ⋅ × |.%| & ∩ ⊗ |.*| |\\| |.\\|) + (* / |./| ÷ ∣ ∤ % ⋅ × |.%| |.*| |\\| |.\\| & ∩ ∧ ⊗ ⊘ ⊙ ⊚ ⊛ ⦸ ⦼ ⊠ ⊡) (// .// ⫽) (^ |.^|) (|::|) From 970938e5030d3d51ffc065bcf035650d1b888156 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Sat, 3 May 2014 14:47:48 -0400 Subject: [PATCH 19/19] update set of unicode operators and fix exports --- base/exports.jl | 5 ----- base/linalg.jl | 2 -- base/linalg/generic.jl | 1 - base/linalg/matmul.jl | 1 - base/operators.jl | 26 ++++++++++++++++++++------ base/rational.jl | 1 - base/sysimg.jl | 2 ++ src/julia-parser.scm | 6 +++--- 8 files changed, 25 insertions(+), 19 deletions(-) diff --git a/base/exports.jl b/base/exports.jl index 845fa852c86fc..5a76266c66929 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -217,7 +217,6 @@ export .^, /, //, - ⫽, <, <:, <<, @@ -236,10 +235,7 @@ export |, ~, :, - ⊗, ÷, - ∣, - ∤, A_ldiv_B!, A_ldiv_Bc, A_ldiv_Bt, @@ -773,7 +769,6 @@ export ⊊, ∩, ∪, - △, # strings and text output ascii, diff --git a/base/linalg.jl b/base/linalg.jl index 47b18f27d64f6..7abb721544057 100644 --- a/base/linalg.jl +++ b/base/linalg.jl @@ -115,8 +115,6 @@ export tril!, triu!, vecnorm, - ⋅, - ×, # Operators \, diff --git a/base/linalg/generic.jl b/base/linalg/generic.jl index 3fc291432c251..9d7cba61b0d5d 100644 --- a/base/linalg/generic.jl +++ b/base/linalg/generic.jl @@ -20,7 +20,6 @@ end scale!(s::Number, X::AbstractArray) = scale!(X, s) cross(a::AbstractVector, b::AbstractVector) = [a[2]*b[3]-a[3]*b[2], a[3]*b[1]-a[1]*b[3], a[1]*b[2]-a[2]*b[1]] -const × = cross triu(M::AbstractMatrix) = triu(M,0) tril(M::AbstractMatrix) = tril(M,0) diff --git a/base/linalg/matmul.jl b/base/linalg/matmul.jl index 60ef6de6a8f38..e8f9da37c20ec 100644 --- a/base/linalg/matmul.jl +++ b/base/linalg/matmul.jl @@ -58,7 +58,6 @@ function dot(x::AbstractVector, y::AbstractVector) s end dot(x::Number, y::Number) = conj(x) * y -const ⋅ = dot Ac_mul_B(x::Vector, y::Vector) = [dot(x, y)] At_mul_B{T<:Real}(x::Vector{T}, y::Vector{T}) = [dot(x, y)] At_mul_B{T<:BlasComplex}(x::Vector{T}, y::Vector{T}) = [BLAS.dotu(x, y)] diff --git a/base/operators.jl b/base/operators.jl index b6255d495dd02..2471220f322d1 100644 --- a/base/operators.jl +++ b/base/operators.jl @@ -111,10 +111,7 @@ fld{T<:Real}(x::T, y::T) = convert(T,round((x-mod(x,y))/y)) # operator alias const % = rem .%(x::Real, y::Real) = x%y -const ⊗ = kron const ÷ = div -∣(x::Real, y::Real) = y%x==0 #x∣y = x divides y -∤(x::Real, y::Real) = !∣(x,y) # mod returns in [0,y) whereas mod1 returns in (0,y] mod1{T<:Real}(x::T, y::T) = y-mod(y-x,y) @@ -354,7 +351,7 @@ function ifelse(c::AbstractArray{Bool}, x, y::AbstractArray) end # some operators not defined yet -global //, .>>, .<<, >:, <|, |>, hcat, hvcat +global //, .>>, .<<, >:, <|, |>, hcat, hvcat, ⋅, ×, ∈, ∉, ∋, ∌, ⊆, ⊈, ⊊, ∩, ∪ module Operators @@ -391,6 +388,12 @@ export ==, >, >=, + ≥, + ≤, + ≠, + .≥, + .≤, + .≠, >>, .>>, .<<, @@ -401,8 +404,18 @@ export |>, <|, ~, - ⊗, ÷, + ⋅, + ×, + ∈, + ∉, + ∋, + ∌, + ⊆, + ⊈, + ⊊, + ∩, + ∪, colon, hcat, vcat, @@ -415,6 +428,7 @@ export import Base: !, !=, $, %, .%, &, *, +, -, .!=, .+, .-, .*, ./, .<, .<=, .==, .>, .>=, .\, .^, /, //, <, <:, <<, <=, ==, >, >=, >>, .>>, .<<, >>>, <|, |>, \, ^, |, ~, !==, >:, colon, hcat, vcat, hvcat, getindex, setindex!, - transpose, ctranspose + transpose, ctranspose, + ≥, ≤, ≠, .≥, .≤, .≠, ÷, ⋅, ×, ∈, ∉, ∋, ∌, ⊆, ⊈, ⊊, ∩, ∪ end diff --git a/base/rational.jl b/base/rational.jl index 4c30ae057c905..2c22105a99465 100644 --- a/base/rational.jl +++ b/base/rational.jl @@ -26,7 +26,6 @@ function //(x::Complex, y::Complex) yy = real(y*y') complex(real(xy)//yy, imag(xy)//yy) end -const ⫽ = // function show(io::IO, x::Rational) if isinf(x) diff --git a/base/sysimg.jl b/base/sysimg.jl index 39a0ab7d1194c..67eb3e0e9b26e 100644 --- a/base/sysimg.jl +++ b/base/sysimg.jl @@ -216,6 +216,8 @@ include("sparse.jl") importall .SparseMatrix include("linalg.jl") importall .LinAlg +const ⋅ = dot +const × = cross include("broadcast.jl") importall .Broadcast diff --git a/src/julia-parser.scm b/src/julia-parser.scm index 59cab060700c5..6a0040ec719e8 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -10,10 +10,10 @@ (> < >= ≥ <= ≤ == === ≡ != ≠ !== ≢ |.>| |.<| |.>=| |.≥| |.<=| |.≤| |.==| |.!=| |.≠| |.=| |.!| |<:| |>:| ∈ ∉ ∋ ∌ ⊆ ⊈ ⊂ ⊄ ⊊) (|\|>| |<\||) (: |..|) - (+ - ⊕ ⊖ ⊞ ⊟ |.+| |.-| |\|| ∪ ∨ $ △) + (+ - ⊕ ⊖ ⊞ ⊟ |.+| |.-| |\|| ∪ ∨ $ ⊓) (<< >> >>> |.<<| |.>>| |.>>>|) - (* / |./| ÷ ∣ ∤ % ⋅ × |.%| |.*| |\\| |.\\| & ∩ ∧ ⊗ ⊘ ⊙ ⊚ ⊛ ⦸ ⦼ ⊠ ⊡) - (// .// ⫽) + (* / |./| ÷ % ⋅ ∘ × |.%| |.*| |\\| |.\\| & ∩ ∧ ⊗ ⊘ ⊙ ⊚ ⊛ ⊠ ⊡ ⊔) + (// .//) (^ |.^|) (|::|) (|.|)))