Replacements for APL functions take and drop
Replacements for APL functions take and drop
apldrop(a, b, give.indices=FALSE) apldrop(a, b) <- value apltake(a, b, give.indices=FALSE) apltake(a, b) <- value
a |
Array |
b |
Vector of number of indices to take/drop. Length of |
give.indices |
Boolean, with default |
value |
elements to replace |
apltake(a,b)
returns an array of the same dimensionality as
a
. Along dimension i
, if b[i]>0
, the first
b[i]
elements are retained; if b[i]<0
, the last
b[i]
elements are retained.
apldrop(a,b)
returns an array of the same dimensionality as
a
. Along dimension i
, if b[i]>0
, the first
b[i]
elements are dropped if b[i]<0
, the last
b[i]
elements are dropped.
These functions do not drop singleton dimensions. Use drop()
if this is desired.
Robin K. S. Hankin
a <- magichypercube.4n(m=1) apltake(a,c(2,3,2)) apldrop(a,c(1,1,2)) b <- matrix(1:30,5,6) apldrop(b,c(1,-2)) <- -1 b <- matrix(1:110,10,11) apltake(b,2) <- -1 apldrop(b,c(5,-7)) <- -2 b
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.