Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

switch to new comprehension syntax in base/ and examples/

closes #744
  • Loading branch information...
commit b5283f5b5ad6e3258409fd57772b70d6b0eefddd 1 parent f5a2190
@JeffBezanson JeffBezanson authored
View
18 base/abstractarray.jl
@@ -197,8 +197,8 @@ end
function gen_cartesian_map(cache, genbodies, ranges, exargnames, exargs...)
N = length(ranges)
if !has(cache,N)
- dimargnames = { gensym() | i=1:N }
- ivars = { gensym() | i=1:N }
+ dimargnames = { gensym() for i=1:N }
+ ivars = { gensym() for i=1:N }
bodies = genbodies(ivars)
## creating a 2d array, to pass as bodies
@@ -318,15 +318,15 @@ vcat() = Array(None, 0)
hcat() = Array(None, 0)
## cat: special cases
-hcat{T}(X::T...) = [ X[j] | i=1, j=1:length(X) ]
-vcat{T}(X::T...) = [ X[i] | i=1:length(X) ]
+hcat{T}(X::T...) = [ X[j] for i=1, j=1:length(X) ]
+vcat{T}(X::T...) = [ X[i] for i=1:length(X) ]
function hcat{T}(V::AbstractVector{T}...)
height = length(V[1])
for j = 2:length(V)
if length(V[j]) != height; error("hcat: mismatched dimensions"); end
end
- [ V[j][i]::T | i=1:length(V[1]), j=1:length(V) ]
+ [ V[j][i]::T for i=1:length(V[1]), j=1:length(V) ]
end
function vcat{T}(V::AbstractVector{T}...)
@@ -718,7 +718,7 @@ function sub2ind(dims, I::Integer...)
end
sub2ind(dims, I::AbstractVector...) =
- [ sub2ind(dims, map(X->X[i], I)...) | i=1:length(I[1]) ]
+ [ sub2ind(dims, map(X->X[i], I)...) for i=1:length(I[1]) ]
ind2sub(dims::(Integer...), ind::Integer) = ind2sub(dims, int(ind))
ind2sub(dims::(), ind::Integer) = throw(BoundsError())
@@ -829,9 +829,9 @@ function bsxfun(f, a::AbstractArray, b::AbstractArray)
end
c = Array(promote_type(eltype(a),eltype(b)), shp...)
- aidxs = { 1:size(a,i) | i=1:nd }
- bidxs = { 1:size(b,i) | i=1:nd }
- cidxs = { 1:size(c,i) | i=1:nd }
+ aidxs = { 1:size(a,i) for i=1:nd }
+ bidxs = { 1:size(b,i) for i=1:nd }
+ cidxs = { 1:size(c,i) for i=1:nd }
sliceop = function (idxs::Int...)
j = 1
View
54 base/array.jl
@@ -187,12 +187,12 @@ function ref(A::Array, I::Integer...)
end
# note: this is also useful for Ranges
-ref{T<:Integer}(A::Vector, I::AbstractVector{T}) = [ A[i] | i=I ]
-ref{T<:Integer}(A::AbstractVector, I::AbstractVector{T}) = [ A[i] | i=I ]
+ref{T<:Integer}(A::Vector, I::AbstractVector{T}) = [ A[i] for i=I ]
+ref{T<:Integer}(A::AbstractVector, I::AbstractVector{T}) = [ A[i] for i=I ]
-ref{T<:Integer}(A::Matrix, I::AbstractVector{T}, j::Integer) = [ A[i,j] | i=I ]
-ref{T<:Integer}(A::Matrix, I::Integer, J::AbstractVector{T}) = [ A[i,j] | i=I, j=J ]
-ref{T<:Integer}(A::Matrix, I::AbstractVector{T}, J::AbstractVector{T}) = [ A[i,j] | i=I, j=J ]
+ref{T<:Integer}(A::Matrix, I::AbstractVector{T}, j::Integer) = [ A[i,j] for i=I ]
+ref{T<:Integer}(A::Matrix, I::Integer, J::AbstractVector{T}) = [ A[i,j] for i=I, j=J ]
+ref{T<:Integer}(A::Matrix, I::AbstractVector{T}, J::AbstractVector{T}) = [ A[i,j] for i=I, j=J ]
let ref_cache = nothing
global ref
@@ -597,13 +597,13 @@ end
# ^ is difficult, since negative exponents give a different type
-./(x::Array, y::Array ) = reshape( [ x[i] ./ y[i] | i=1:numel(x) ], size(x) )
-./(x::Number,y::Array ) = reshape( [ x ./ y[i] | i=1:numel(y) ], size(y) )
-./(x::Array, y::Number) = reshape( [ x[i] ./ y | i=1:numel(x) ], size(x) )
+./(x::Array, y::Array ) = reshape( [ x[i] ./ y[i] for i=1:numel(x) ], size(x) )
+./(x::Number,y::Array ) = reshape( [ x ./ y[i] for i=1:numel(y) ], size(y) )
+./(x::Array, y::Number) = reshape( [ x[i] ./ y for i=1:numel(x) ], size(x) )
-.^(x::Array, y::Array ) = reshape( [ x[i] ^ y[i] | i=1:numel(x) ], size(x) )
-.^(x::Number,y::Array ) = reshape( [ x ^ y[i] | i=1:numel(y) ], size(y) )
-.^(x::Array, y::Number) = reshape( [ x[i] ^ y | i=1:numel(x) ], size(x) )
+.^(x::Array, y::Array ) = reshape( [ x[i] ^ y[i] for i=1:numel(x) ], size(x) )
+.^(x::Number,y::Array ) = reshape( [ x ^ y[i] for i=1:numel(y) ], size(y) )
+.^(x::Array, y::Number) = reshape( [ x[i] ^ y for i=1:numel(x) ], size(x) )
function .^{S<:Integer,T<:Integer}(A::Array{S}, B::Array{T})
F = Array(Float64, promote_shape(size(A), size(B)))
@@ -849,7 +849,7 @@ rotr90(A::AbstractMatrix, k::Integer) = rotl90(A,-k)
rot180(A::AbstractMatrix, k::Integer) = k % 2 == 1 ? rot180(A) : copy(A)
const rot90 = rotl90
-reverse(v::StridedVector) = (n=length(v); [ v[n-i+1] | i=1:n ])
+reverse(v::StridedVector) = (n=length(v); [ v[n-i+1] for i=1:n ])
function reverse!(v::StridedVector)
n = length(v)
r = n
@@ -904,7 +904,7 @@ end
let findn_cache = nothing
function findn_one(ivars)
- s = { quote I[$i][count] = $ivars[i] end | i = 1:length(ivars)}
+ s = { quote I[$i][count] = $ivars[i] end for i = 1:length(ivars)}
quote
Aind = A[$(ivars...)]
if Aind != z
@@ -977,11 +977,11 @@ areduce{T}(f::Function, A::StridedArray{T}, region::Region, v0) =
let areduce_cache = nothing
# generate the body of the N-d loop to compute a reduction
function gen_areduce_func(n, f)
- ivars = { gensym() | i=1:n }
+ ivars = { gensym() for i=1:n }
# limits and vars for reduction loop
- lo = { gensym() | i=1:n }
- hi = { gensym() | i=1:n }
- rvars = { gensym() | i=1:n }
+ lo = { gensym() for i=1:n }
+ hi = { gensym() for i=1:n }
+ rvars = { gensym() for i=1:n }
setlims = { quote
# each dim of reduction is either 1:sizeA or ivar:ivar
if contains(region,$i)
@@ -990,8 +990,8 @@ function gen_areduce_func(n, f)
else
$lo[i] = $hi[i] = $ivars[i]
end
- end | i=1:n }
- rranges = { :( ($lo[i]):($hi[i]) ) | i=1:n } # lo:hi for all dims
+ end for i=1:n }
+ rranges = { :( ($lo[i]):($hi[i]) ) for i=1:n } # lo:hi for all dims
body =
quote
_tot = v0
@@ -1005,7 +1005,7 @@ function gen_areduce_func(n, f)
local _F_
function _F_(f, A, region, R, v0)
_ind = 1
- $make_loop_nest(ivars, { :(1:size(R,$i)) | i=1:n }, body)
+ $make_loop_nest(ivars, { :(1:size(R,$i)) for i=1:n }, body)
end
_F_
end
@@ -1267,7 +1267,7 @@ function transpose{T<:Union(Float64,Float32,Complex128,Complex64)}(A::Matrix{T})
if numel(A) > 50000
return _jl_fftw_transpose(reshape(A, size(A, 2), size(A, 1)))
else
- return [ A[j,i] | i=1:size(A,2), j=1:size(A,1) ]
+ return [ A[j,i] for i=1:size(A,2), j=1:size(A,1) ]
end
end
@@ -1275,11 +1275,11 @@ ctranspose{T<:Real}(A::StridedVecOrMat{T}) = transpose(A)
ctranspose(x::StridedVecOrMat) = transpose(x)
-transpose(x::StridedVector) = [ x[j] | i=1, j=1:size(x,1) ]
-transpose(x::StridedMatrix) = [ x[j,i] | i=1:size(x,2), j=1:size(x,1) ]
+transpose(x::StridedVector) = [ x[j] for i=1, j=1:size(x,1) ]
+transpose(x::StridedMatrix) = [ x[j,i] for i=1:size(x,2), j=1:size(x,1) ]
-ctranspose{T<:Number}(x::StridedVector{T}) = [ conj(x[j]) | i=1, j=1:size(x,1) ]
-ctranspose{T<:Number}(x::StridedMatrix{T}) = [ conj(x[j,i]) | i=1:size(x,2), j=1:size(x,1) ]
+ctranspose{T<:Number}(x::StridedVector{T}) = [ conj(x[j]) for i=1, j=1:size(x,1) ]
+ctranspose{T<:Number}(x::StridedMatrix{T}) = [ conj(x[j,i]) for i=1:size(x,2), j=1:size(x,1) ]
## Permute ##
@@ -1296,7 +1296,7 @@ function permute(A::StridedArray, perm)
end
#calculates all the strides
- strides = [ stride(A, perm[dim]) | dim = 1:length(perm) ]
+ strides = [ stride(A, perm[dim]) for dim = 1:length(perm) ]
#Creates offset, because indexing starts at 1
offset = 0
@@ -1307,7 +1307,7 @@ function permute(A::StridedArray, perm)
function permute_one(ivars)
len = length(ivars)
- counts = { gensym() | i=1:len}
+ counts = { gensym() for i=1:len}
toReturn = cell(len+1,2)
for i = 1:numel(toReturn)
toReturn[i] = nothing
View
6 base/cell.jl
@@ -36,12 +36,12 @@ function cell_2d(nr, nc, xs::ANY...)
end
# map cell array
-map(f, a::Array{Any,1}) = { f(a[i]) | i=1:length(a) }
+map(f, a::Array{Any,1}) = { f(a[i]) for i=1:length(a) }
map(f, a::Array{Any,1}, b::Array{Any,1}) =
- { f(a[i],b[i]) | i=1:length_checked_equal(a, b) }
+ { f(a[i],b[i]) for i=1:length_checked_equal(a, b) }
function map(f, as::Array{Any,1}...)
n = length_checked_equal(as...)
- { f(map(a->a[i],as)...) | i=1:n }
+ { f(map(a->a[i],as)...) for i=1:n }
end
cell(dims::(Integer...)) = Array(Any, map(int, dims))
View
6 base/combinatorics.jl
@@ -60,7 +60,7 @@ end
const nCr = binomial
-pascal(n) = [binomial(i+j-2,i-1) | i=1:n,j=1:n]
+pascal(n) = [binomial(i+j-2,i-1) for i=1:n,j=1:n]
## other ordering related functions ##
@@ -137,7 +137,7 @@ function combinations(a::AbstractVector, t::Integer)
else
while true
# T2
- produce([ a[c[i]+1] | i=1:t ])
+ produce([ a[c[i]+1] for i=1:t ])
if j > 0
x = j
@@ -236,7 +236,7 @@ function partitions{T}(s::AbstractVector{T})
while true
# H2
# convert from restricted growth string a[1:n] to set of sets
- temp = [ Array(T,0) | k = 1:n ]
+ temp = [ Array(T,0) for k = 1:n ]
for k = 1:n
push(temp[a[k]+1], s[k])
end
View
8 base/darray.jl
@@ -189,7 +189,7 @@ procs(s::SubDArray) = s.parent.pmap[_jl_sub_da_pieces(s)]
function dist(s::SubDArray)
pcs = _jl_sub_da_pieces(s)
- sizes = [ length(pieceindex(s, p)) | p = pcs ]
+ sizes = [ length(pieceindex(s, p)) for p = pcs ]
cumsum([1, sizes])
end
@@ -356,7 +356,7 @@ function _jl_distribute_one(T, lsz, da, distdim, owner, orig_array)
i1 = da.dist[p] # my first index in distdim
iend = i1+lsz[distdim]-1 # my last "
# indexes of original array I will take
- idxs = { 1:lsz[i] | i=1:length(da.dims) }
+ idxs = { 1:lsz[i] for i=1:length(da.dims) }
idxs[distdim] = (i1:iend)
remote_call_fetch(owner, ref, orig_array, idxs...)
end
@@ -365,7 +365,7 @@ convert{T,N}(::Type{Array}, d::DArray{T,N}) = convert(Array{T,N}, d)
function convert{S,T,N}(::Type{Array{S,N}}, d::DArray{T,N})
a = Array(S, size(d))
- idxs = { 1:size(a,i) | i=1:N }
+ idxs = { 1:size(a,i) for i=1:N }
for p = 1:length(d.dist)-1
idxs[d.distdim] = d.dist[p]:(d.dist[p+1]-1)
a[idxs...] = remote_call_fetch(d.pmap[p], localize, d)
@@ -878,7 +878,7 @@ end # for
function reduce(f, v::DArray)
mapreduce(f, fetch,
- { @spawnat p reduce(f,localize(v)) | p = procs(v) })
+ { @spawnat p reduce(f,localize(v)) for p = procs(v) })
end
sum(d::DArray) = reduce(+, d)
View
10 base/inference.jl
@@ -925,7 +925,7 @@ function typeinf(linfo::LambdaStaticData,atypes::Tuple,sparams::Tuple, def, cop)
rec = false
- s = { () | i=1:n }
+ s = { () for i=1:n }
recpts = IntSet(n+1) # statements that depend recursively on our value
W = IntSet(n+1)
# initial set of pc
@@ -972,7 +972,7 @@ function typeinf(linfo::LambdaStaticData,atypes::Tuple,sparams::Tuple, def, cop)
# exception handlers
cur_hand = ()
- handler_at = { () | i=1:n }
+ handler_at = { () for i=1:n }
while !isempty(W)
pc = choose(W)
@@ -1399,7 +1399,7 @@ function inlineable(f, e::Expr, vars)
return NF
end
# ok, substitute argument expressions for argument names in the body
- spnames = { sp[i].name | i=1:2:length(sp) }
+ spnames = { sp[i].name for i=1:2:length(sp) }
return sym_replace(copy(expr), append(args,spnames),
append(argexprs,spvals))
end
@@ -1487,7 +1487,7 @@ function inlining_pass(e::Expr, vars)
newargs[i-2] = aarg.args[2:]
elseif isa(t,Tuple) && isleaftype(t)
# apply(f,t::(x,y)) => f(t[1],t[2])
- newargs[i-2] = { _jl_mk_tupleref(aarg,j) | j=1:length(t) }
+ newargs[i-2] = { _jl_mk_tupleref(aarg,j) for j=1:length(t) }
else
# not all args expandable
return e
@@ -1547,7 +1547,7 @@ function tuple_elim_pass(ast::Expr)
if nv > 0
del(body, i) # remove (multiple_value)
del(body, i) # remove tuple allocation
- vals = { unique_name(ast) | j=1:nv }
+ vals = { unique_name(ast) for j=1:nv }
# convert tuple allocation to a series of assignments
# to local variables
for j=1:nv
View
2  base/iterator.jl
@@ -22,7 +22,7 @@ end
zip(itrs...) = Zip(itrs...)
length(z::Zip) = min(length, z.itrs)
-start(z::Zip) = { start(itr) | itr in z.itrs }
+start(z::Zip) = { start(itr) for itr in z.itrs }
function next(z::Zip, state)
v = Array(Any, length(z.itrs))
s = Array(Any, length(z.itrs))
View
18 base/linalg_dense.jl
@@ -148,18 +148,18 @@ function matmul3x3{T,S}(tA, tB, A::Matrix{T}, B::Matrix{S})
end
-triu{T}(M::Matrix{T}, k::Integer) = [ j-i >= k ? M[i,j] : zero(T) |
- i=1:size(M,1), j=1:size(M,2) ]
-tril{T}(M::Matrix{T}, k::Integer) = [ j-i <= k ? M[i,j] : zero(T) |
- i=1:size(M,1), j=1:size(M,2) ]
+triu{T}(M::Matrix{T}, k::Integer) = [ j-i >= k ? M[i,j] : zero(T) for
+ i=1:size(M,1), j=1:size(M,2) ]
+tril{T}(M::Matrix{T}, k::Integer) = [ j-i <= k ? M[i,j] : zero(T) for
+ i=1:size(M,1), j=1:size(M,2) ]
-diff(a::Vector) = [ a[i+1] - a[i] | i=1:length(a)-1 ]
+diff(a::Vector) = [ a[i+1] - a[i] for i=1:length(a)-1 ]
function diff(a::Matrix, dim::Integer)
if dim == 1
- [ a[i+1,j] - a[i,j] | i=1:size(a,1)-1, j=1:size(a,2) ]
+ [ a[i+1,j] - a[i,j] for i=1:size(a,1)-1, j=1:size(a,2) ]
else
- [ a[i,j+1] - a[i,j] | i=1:size(a,1), j=1:size(a,2)-1 ]
+ [ a[i,j+1] - a[i,j] for i=1:size(a,1), j=1:size(a,2)-1 ]
end
end
@@ -180,7 +180,7 @@ function gradient(F::Vector, h::Vector)
return g
end
-diag(A::Matrix) = [ A[i,i] | i=1:min(size(A,1),size(A,2)) ]
+diag(A::Matrix) = [ A[i,i] for i=1:min(size(A,1),size(A,2)) ]
function diagm{T}(v::Union(Vector{T},Matrix{T}))
if isa(v, Matrix)
@@ -206,7 +206,7 @@ function trace{T}(A::Matrix{T})
return t
end
-kron(a::Vector, b::Vector) = [ a[i]*b[j] | i=1:length(a), j=1:length(b) ]
+kron(a::Vector, b::Vector) = [ a[i]*b[j] for i=1:length(a), j=1:length(b) ]
function kron{T,S}(a::Matrix{T}, b::Matrix{S})
R = Array(promote_type(T,S), size(a,1)*size(b,1), size(a,2)*size(b,2))
View
2  base/linalg_lapack.jl
@@ -612,7 +612,7 @@ function (\){T<:Union(Float64,Float32,Complex128,Complex64)}(A::StridedMatrix{T}
ipiv = Array(Int32, n)
# Check for SPD matrix
- if ishermitian(Acopy) && all([ Acopy[i,i] > 0 | i=1:n ])
+ if ishermitian(Acopy) && all([ Acopy[i,i] > 0 for i=1:n ])
case = :spd
end
View
12 base/multi.jl
@@ -1028,8 +1028,8 @@ end #func
function addprocs_ssh(machines, keys)
if !(isa(keys, Array)) && isa(machines,Array)
key = keys
- keys = [ key | x = 1:numel(machines)]
- cmdargs = { {machines[x],keys[x]} | x = 1:numel(machines)}
+ keys = [ key for x = 1:numel(machines)]
+ cmdargs = { {machines[x],keys[x]} for x = 1:numel(machines)}
else
cmdargs = {{machines,keys}}
end #if/else
@@ -1039,8 +1039,8 @@ end #func
worker_local_cmd() = `$JULIA_HOME/julia --worker`
addprocs_local(np::Integer) =
- add_workers(PGRP, start_remote_workers({ "localhost" | i=1:np },
- { worker_local_cmd() | i=1:np }))
+ add_workers(PGRP, start_remote_workers({ "localhost" for i=1:np },
+ { worker_local_cmd() for i=1:np }))
function start_sge_workers(n)
@@ -1176,7 +1176,7 @@ type GlobalObject
midx = i
end
end
- rids = { rr2id(r[i]) | i=1:np }
+ rids = { rr2id(r[i]) for i=1:np }
for p in procs
if p != mi
remote_do(p, init_GlobalObject, p, procs, rids, initializer)
@@ -1393,7 +1393,7 @@ end
function pmap_static(f, lsts...)
np = nprocs()
n = length(lsts[1])
- { remote_call((i-1)%np+1, f, map(L->L[i], lsts)...) | i = 1:n }
+ { remote_call((i-1)%np+1, f, map(L->L[i], lsts)...) for i = 1:n }
end
pmap(f) = f()
View
12 base/operators.jl
@@ -147,13 +147,13 @@ end
macro vectorize_1arg(S,f)
quote
function ($f){T<:$S}(x::AbstractArray{T,1})
- [ ($f)(x[i]) | i=1:length(x) ]
+ [ ($f)(x[i]) for i=1:length(x) ]
end
function ($f){T<:$S}(x::AbstractArray{T,2})
- [ ($f)(x[i,j]) | i=1:size(x,1), j=1:size(x,2) ]
+ [ ($f)(x[i,j]) for i=1:size(x,1), j=1:size(x,2) ]
end
function ($f){T<:$S}(x::AbstractArray{T})
- reshape([ ($f)(x[i]) | i=1:numel(x) ], size(x))
+ reshape([ ($f)(x[i]) for i=1:numel(x) ], size(x))
end
end
end
@@ -161,15 +161,15 @@ end
macro vectorize_2arg(S,f)
quote
function ($f){T1<:$S, T2<:$S}(x::T1, y::AbstractArray{T2})
- reshape([ ($f)(x, y[i]) | i=1:numel(y) ], size(y))
+ reshape([ ($f)(x, y[i]) for i=1:numel(y) ], size(y))
end
function ($f){T1<:$S, T2<:$S}(x::AbstractArray{T1}, y::T2)
- reshape([ ($f)(x[i], y) | i=1:numel(x) ], size(x))
+ reshape([ ($f)(x[i], y) for i=1:numel(x) ], size(x))
end
function ($f){T1<:$S, T2<:$S}(x::AbstractArray{T1}, y::AbstractArray{T2})
shp = promote_shape(size(x),size(y))
- reshape([ ($f)(x[i], y[i]) | i=1:numel(x) ], shp)
+ reshape([ ($f)(x[i], y[i]) for i=1:numel(x) ], shp)
end
end
end
View
14 base/range.jl
@@ -157,29 +157,29 @@ end
## non-linear operations on ranges ##
-./(x::Number, r::Ranges) = [ x/y | y=r ]
-./(r::Ranges, y::Number) = [ x/y | x=r ]
+./(x::Number, r::Ranges) = [ x/y for y=r ]
+./(r::Ranges, y::Number) = [ x/y for x=r ]
function ./(r::Ranges, s::Ranges)
if length(r) != length(s)
error("argument dimensions must match")
end
- [ r[i]/s[i] | i = 1:length(r) ]
+ [ r[i]/s[i] for i = 1:length(r) ]
end
function .*(r::Ranges, s::Ranges)
if length(r) != length(s)
error("argument dimensions must match")
end
- [ r[i]*s[i] | i = 1:length(r) ]
+ [ r[i]*s[i] for i = 1:length(r) ]
end
-.^(x::Number, r::Ranges) = [ x^y | y=r ]
-.^(r::Ranges, y::Number) = [ x^y | x=r ]
+.^(x::Number, r::Ranges) = [ x^y for y=r ]
+.^(r::Ranges, y::Number) = [ x^y for x=r ]
function .^(r::Ranges, s::Ranges)
if length(r) != length(s)
error("argument dimensions must match")
end
- [ r[i]^s[i] | i = 1:length(r) ]
+ [ r[i]^s[i] for i = 1:length(r) ]
end
## concatenation ##
View
2  base/serialize.jl
@@ -294,7 +294,7 @@ deserialize(s, ::Type{LongExpr}) = deserialize_expr(s, read(s, Int32))
function deserialize_expr(s, len)
hd = deserialize(s)::Symbol
ty = force(deserialize(s))
- args = { deserialize(s) | i=1:len }
+ args = { deserialize(s) for i=1:len }
function ()
e = expr(hd, map(force, args))
e.typ = ty
View
4 base/signal_fftw.jl
@@ -200,7 +200,7 @@ for (fname,direction) in ((:fft,:_jl_FFTW_FORWARD),(:ifft,:_jl_FFTW_BACKWARD))
@eval begin
function ($fname){T<:Union(Complex128,Complex64)}(X::Array{T}, dim::Int)
s = [size(X)...]
- strides = [ prod(s[1:i-1]) | i=1:length(s) ]
+ strides = [ prod(s[1:i-1]) for i=1:length(s) ]
dims = [s[dim],strides[dim],strides[dim]]''
del(s, dim)
del(strides, dim)
@@ -214,7 +214,7 @@ for (fname,direction) in ((:fft,:_jl_FFTW_FORWARD),(:ifft,:_jl_FFTW_BACKWARD))
function ($fname){T<:Union(Float64,Float32)}(X::Array{T}, dim::Int)
s = [size(X)...]
- strides = [ prod(s[1:i-1]) | i=1:length(s) ]
+ strides = [ prod(s[1:i-1]) for i=1:length(s) ]
n = s[dim]
dims = [n,strides[dim],strides[dim]]''
del(s, dim)
View
2  base/statistics.jl
@@ -375,5 +375,5 @@ function _bound_quantiles(qs)
if (any(qs < -epsilon) || any(qs > 1 + epsilon))
error("quantiles out of [0,1] range!")
end
- [min(1, max(0, q)) | q = qs]
+ [min(1, max(0, q)) for q = qs]
end
View
2  base/string.jl
@@ -244,7 +244,7 @@ type CharString <: String
chars::Array{Char,1}
CharString(a::Array{Char,1}) = new(a)
- CharString(c::Char...) = new([ c[i] | i=1:length(c) ])
+ CharString(c::Char...) = new([ c[i] for i=1:length(c) ])
end
CharString(x...) = CharString(map(char,x)...)
View
2  examples/colorimetry.jl
@@ -475,7 +475,7 @@ const cie_color_match =
# compute the perceived color of a spectral distribution function
function spectrum2xyz(intensity::Function)
- Me = [ intensity(i) | i=380:780 ]
+ Me = [ intensity(i) for i=380:780 ]
X = dot(Me, cie_color_match[1, :])
Y = dot(Me, cie_color_match[2, :])
Z = dot(Me, cie_color_match[3, :])
View
2  examples/ndrange.jl
@@ -25,7 +25,7 @@ start(r::NDRange{0}) = false
done(r::NDRange{0}, st) = st
next(r::NDRange{0}, st) = ((), true)
-start(r::NDRange) = { start(r.ranges[i]) | i=1:length(r.ranges) }
+start(r::NDRange) = { start(r.ranges[i]) for i=1:length(r.ranges) }
done(r::NDRange, st) = r.empty || !bool(st)
function next{N}(r::NDRange{N}, st)
View
6 examples/preduce.jl
@@ -2,7 +2,7 @@
# sum a vector using a tree on top of local reductions.
function sum(v::DArray)
P = procs(v)
- nodeval = { RemoteRef(p) | p=P }
+ nodeval = { RemoteRef(p) for p=P }
answer = RemoteRef()
np = numel(P)
@@ -29,7 +29,7 @@ end
function reduce(f, v::DArray)
mapreduce(f, fetch,
- { @spawnat p reduce(f,localize(v)) | p = procs(v) })
+ { @spawnat p reduce(f,localize(v)) for p = procs(v) })
end
# possibly-useful abstraction:
@@ -37,7 +37,7 @@ end
type RefGroup
refs::Array{RemoteRef,1}
- RefGroup(P) = new([ RemoteRef(p) | p=P ])
+ RefGroup(P) = new([ RemoteRef(p) for p=P ])
end
ref(r::RefGroup, i) = fetch(r.refs[i])
View
2  examples/regexdna.jl
@@ -17,7 +17,7 @@ const variants = [
"agggtaa[cgt]|[acg]ttaccct" ]
for variant in variants
- k = sum([1 | mat in each_match(Regex(variant), seq)])
+ k = sum([1 for mat in each_match(Regex(variant), seq)])
printf("%s %d\n", variant, k)
end
View
5 src/julia-parser.scm
@@ -791,7 +791,8 @@
(let loop ((exprs '()))
(if (or (closing-token? (peek-token s))
(newline? (peek-token s))
- (and inside-vec (eq? (peek-token s) '|\||)))
+ (and inside-vec (or (eq? (peek-token s) '|\||)
+ (eq? (peek-token s) 'for))))
(reverse! exprs)
(let ((e (parse-eq s)))
(case (peek-token s)
@@ -899,6 +900,8 @@
;; dispatch to array syntax, comprehension, or matrix syntax
((#\,)
(parse-vcat s first closer))
+ ;;((|\||)
+ ;; (error "old syntax"))
((|\|| for)
(take-token s)
(let ((r (parse-comma-separated-iters s)))

1 comment on commit b5283f5

@StefanKarpinski

Awesomeness!

Please sign in to comment.
Something went wrong with that request. Please try again.