Permalink
Browse files

make function first argument of map_to. fixes #1077

  • Loading branch information...
1 parent 70cafda commit b4ccae43de6f1159625841ba8d4e505ff79f4d58 @JeffBezanson JeffBezanson committed Jul 28, 2012
Showing with 22 additions and 22 deletions.
  1. +15 −15 base/array.jl
  2. +1 −1 base/darray.jl
  3. +1 −1 base/range.jl
  4. +5 −5 extras/bitarray.jl
View
@@ -1480,13 +1480,13 @@ end
## 1 argument
-function map_to(dest::StridedArray, f, A::StridedArray)
+function map_to(f, dest::StridedArray, A::StridedArray)
for i=1:numel(A)
dest[i] = f(A[i])
end
return dest
end
-function map_to2(first, dest::StridedArray, f, A::StridedArray)
+function map_to2(f, first, dest::StridedArray, A::StridedArray)
dest[1] = first
for i=2:numel(A)
dest[i] = f(A[i])
@@ -1498,17 +1498,17 @@ function map(f, A::StridedArray)
if isempty(A); return A; end
first = f(A[1])
dest = similar(A, typeof(first))
- return map_to2(first, dest, f, A)
+ return map_to2(f, first, dest, A)
end
## 2 argument
-function map_to(dest::StridedArray, f, A::StridedArray, B::StridedArray)
+function map_to(f, dest::StridedArray, A::StridedArray, B::StridedArray)
for i=1:numel(A)
dest[i] = f(A[i], B[i])
end
return dest
end
-function map_to2(first, dest::StridedArray, f,
+function map_to2(f, first, dest::StridedArray,
A::StridedArray, B::StridedArray)
dest[1] = first
for i=2:numel(A)
@@ -1524,16 +1524,16 @@ function map(f, A::StridedArray, B::StridedArray)
end
first = f(A[1], B[1])
dest = similar(A, typeof(first), shp)
- return map_to2(first, dest, f, A, B)
+ return map_to2(f, first, dest, A, B)
end
-function map_to(dest::StridedArray, f, A::StridedArray, B::Number)
+function map_to(f, dest::StridedArray, A::StridedArray, B::Number)
for i=1:numel(A)
dest[i] = f(A[i], B)
end
return dest
end
-function map_to2(first, dest::StridedArray, f, A::StridedArray, B::Number)
+function map_to2(f, first, dest::StridedArray, A::StridedArray, B::Number)
dest[1] = first
for i=2:numel(A)
dest[i] = f(A[i], B)
@@ -1545,16 +1545,16 @@ function map(f, A::StridedArray, B::Number)
if isempty(A); return A; end
first = f(A[1], B)
dest = similar(A, typeof(first))
- return map_to2(first, dest, f, A, B)
+ return map_to2(f, first, dest, A, B)
end
-function map_to(dest::StridedArray, f, A::Number, B::StridedArray)
+function map_to(f, dest::StridedArray, A::Number, B::StridedArray)
for i=1:numel(B)
dest[i] = f(A, B[i])
end
return dest
end
-function map_to2(first, dest::StridedArray, f, A::Number, B::StridedArray)
+function map_to2(f, first, dest::StridedArray, A::Number, B::StridedArray)
dest[1] = first
for i=2:numel(B)
dest[i] = f(A, B[i])
@@ -1566,11 +1566,11 @@ function map(f, A::Number, B::StridedArray)
if isempty(A); return A; end
first = f(A, B[1])
dest = similar(B, typeof(first))
- return map_to2(first, dest, f, A, B)
+ return map_to2(f, first, dest, A, B)
end
## N argument
-function map_to(dest::StridedArray, f, As::StridedArray...)
+function map_to(f, dest::StridedArray, As::StridedArray...)
n = numel(As[1])
i = 1
ith = a->a[i]
@@ -1579,7 +1579,7 @@ function map_to(dest::StridedArray, f, As::StridedArray...)
end
return dest
end
-function map_to2(first, dest::StridedArray, f, As::StridedArray...)
+function map_to2(f, first, dest::StridedArray, As::StridedArray...)
n = numel(As[1])
i = 1
ith = a->a[i]
@@ -1597,7 +1597,7 @@ function map(f, As::StridedArray...)
end
first = f(map(a->a[1], As)...)
dest = similar(As[1], typeof(first), shape)
- return map_to2(first, dest, f, As...)
+ return map_to2(f, first, dest, As...)
end
## Filter ##
View
@@ -834,7 +834,7 @@ end # for
function map(f, A::SubOrDArray)
T = typeof(f(A[1]))
- darray((T,lsz,da)->map_to(Array(T,lsz), f, localize(A, da)),
+ darray((T,lsz,da)->map_to(f, Array(T,lsz), localize(A, da)),
T, size(A), distdim(A), procs(A))
end
View
@@ -229,7 +229,7 @@ function sum(r::Ranges)
return l * first(r) + step(r) * div(l * (l - 1), 2)
end
-function map_to(dest, f, r::Ranges)
+function map_to(f, dest, r::Ranges)
i = 1
for ri in r dest[i] = f(ri); i+=1; end
dest
View
@@ -1485,35 +1485,35 @@ max{T}(B::BitArray{T}) = length(B) > 0 ? (nnz(B) > 0 ? one(T) : zero(T)) : typem
## map over bitarrays ##
-function map_to(dest::BitArray, f, A::Union(StridedArray,BitArray))
+function map_to(f, dest::BitArray, A::Union(StridedArray,BitArray))
for i=1:numel(A)
dest[i] = f(A[i])
end
return dest
end
-function map_to(dest::BitArray, f, A::Union(StridedArray,BitArray), B::Union(StridedArray,BitArray))
+function map_to(f, dest::BitArray, A::Union(StridedArray,BitArray), B::Union(StridedArray,BitArray))
for i=1:numel(A)
dest[i] = f(A[i], B[i])
end
return dest
end
-function map_to(dest::BitArray, f, A::Union(StridedArray,BitArray), B::Number)
+function map_to(f, dest::BitArray, A::Union(StridedArray,BitArray), B::Number)
for i=1:numel(A)
dest[i] = f(A[i], B)
end
return dest
end
-function map_to(dest::BitArray, f, A::Number, B::Union(StridedArray,BitArray))
+function map_to(f, dest::BitArray, A::Number, B::Union(StridedArray,BitArray))
for i=1:numel(B)
dest[i] = f(A, B[i])
end
return dest
end
-function map_to(dest::BitArray, f, As::Union(StridedArray,BitArray)...)
+function map_to(f, dest::BitArray, As::Union(StridedArray,BitArray)...)
n = numel(As[1])
i = 1
ith = a->a[i]

0 comments on commit b4ccae4

Please sign in to comment.