diff --git a/base/exports.jl b/base/exports.jl index 55ebf638c4b43..5a76266c66929 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -190,7 +190,10 @@ export # Operators !, !=, + ≠, !==, + ≡, + ≢, $, %, &, @@ -198,15 +201,18 @@ export +, -, .!=, + .≠, .+, .-, .*, ./, .<, .<=, + .≤, .==, .>, .>=, + .≥, .\, .^, /, @@ -215,9 +221,11 @@ export <:, <<, <=, + ≤, ==, >, >=, + ≥, >>, #.>>, #.<<, @@ -227,6 +235,7 @@ export |, ~, :, + ÷, A_ldiv_B!, A_ldiv_Bc, A_ldiv_Bt, @@ -442,6 +451,7 @@ export unsigned, widemul, zero, + √, # specfun airy, @@ -660,6 +670,8 @@ export triu!, triu, vecnorm, + ⋅, + ×, # sparse etree, @@ -746,6 +758,17 @@ export union, unique, values, + ∈, + ∉, + ∋, + ∌, + ⊆, + ⊈, + ⊂, + ⊄, + ⊊, + ∩, + ∪, # strings and text output ascii, diff --git a/base/math.jl b/base/math.jl index 36b2525706532..bea201d0988ec 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, @@ -284,6 +284,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 diff --git a/base/operators.jl b/base/operators.jl index dfe1243b5158b..2471220f322d1 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: @@ -84,6 +89,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) @@ -104,6 +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 ÷ = div # mod returns in [0,y) whereas mod1 returns in (0,y] mod1{T<:Real}(x::T, y::T) = y-mod(y-x,y) @@ -343,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 @@ -380,6 +388,12 @@ export ==, >, >=, + ≥, + ≤, + ≠, + .≥, + .≤, + .≠, >>, .>>, .<<, @@ -390,6 +404,18 @@ export |>, <|, ~, + ÷, + ⋅, + ×, + ∈, + ∉, + ∋, + ∌, + ⊆, + ⊈, + ⊊, + ∩, + ∪, colon, hcat, vcat, @@ -402,6 +428,7 @@ export import Base: !, !=, $, %, .%, &, *, +, -, .!=, .+, .-, .*, ./, .<, .<=, .==, .>, .>=, .\, .^, /, //, <, <:, <<, <=, ==, >, >=, >>, .>>, .<<, >>>, <|, |>, \, ^, |, ~, !==, >:, colon, hcat, vcat, hvcat, getindex, setindex!, - transpose, ctranspose + transpose, ctranspose, + ≥, ≤, ≠, .≥, .≤, .≠, ÷, ⋅, ×, ∈, ∉, ∋, ∌, ⊆, ⊈, ⊊, ∩, ∪ end diff --git a/base/reduce.jl b/base/reduce.jl index 5c81a0bafa051..f1f6b392f69a5 100644 --- a/base/reduce.jl +++ b/base/reduce.jl @@ -121,6 +121,10 @@ function in(x, itr) end return false end +const ∈ = in +∉(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/base/set.jl b/base/set.jl index ee3421c78924c..297a31d007453 100644 --- a/base/set.jl +++ b/base/set.jl @@ -50,6 +50,7 @@ function union(s::Set, sets::Set...) end return u end +const ∪ = union intersect(s::Set) = copy(s) function intersect(s::Set, sets::Set...) @@ -64,6 +65,7 @@ function intersect(s::Set, sets::Set...) end return i end +const ∩ = intersect function setdiff(a::Set, b::Set) d = copy(a) @@ -85,6 +87,9 @@ function issubset(l, r) end return true end +const ⊆ = issubset +⊊(l::Set, r::Set) = ⊆(l, r) && l!=r +⊈(l::Set, r::Set) = !⊆(l, r) function unique(C) out = Array(eltype(C),0) 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 a87aa72ca0509..6a0040ec719e8 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -7,12 +7,12 @@ ; the way the lexer works, every prefix of an operator must also ; be an operator. (-- -->) - (> < >= <= == === != !== |.>| |.<| |.>=| |.<=| |.==| |.!=| |.=| |.!| |<:| |>:|) + (> < >= ≥ <= ≤ == === ≡ != ≠ !== ≢ |.>| |.<| |.>=| |.≥| |.<=| |.≤| |.==| |.!=| |.≠| |.=| |.!| |<:| |>:| ∈ ∉ ∋ ∌ ⊆ ⊈ ⊂ ⊄ ⊊) (|\|>| |<\||) (: |..|) - (+ - |.+| |.-| |\|| $) + (+ - ⊕ ⊖ ⊞ ⊟ |.+| |.-| |\|| ∪ ∨ $ ⊓) (<< >> >>> |.<<| |.>>| |.>>>|) - (* / |./| % |.%| & |.*| |\\| |.\\|) + (* / |./| ÷ % ⋅ ∘ × |.%| |.*| |\\| |.\\| & ∩ ∧ ⊗ ⊘ ⊙ ⊚ ⊛ ⊠ ⊡ ⊔) (// .//) (^ |.^|) (|::|)