funprog-methods {IRanges} | R Documentation |
The R base package defines some higher-order functions that are commonly
found in Functional Programming Languages. See ?Reduce
for the details, and, in particular, for a description of their arguments.
The IRanges package provides methods for List objects, so, in addition
to be an ordinary vector or list, the x
argument can also be a
List object.
## S4 method for signature 'List' Reduce(f, x, init, right=FALSE, accumulate=FALSE) ## S4 method for signature 'List' Filter(f, x) ## S4 method for signature 'List' Find(f, x, right=FALSE, nomatch=NULL) ## S4 method for signature 'List' Map(f, ...) ## S4 method for signature 'List' Position(f, x, right=FALSE, nomatch=NA_integer_)
f, init, right, accumulate, nomatch |
See |
x |
A List object. |
... |
One or more List objects. (FIXME: Mixing List objects with ordinary lists doesn't seem to work properly at the moment.) |
P. Aboyoun
The List class.
The IntegerList class and constructor for an example of a List subclass.
Reduce
for a full description of what these
functions do and what they return.
x <- IntegerList(a=1:3, b=16:11, c=22:21, d=31:36) x Reduce("+", x) Filter(is.unsorted, x) pos1 <- Position(is.unsorted, x) stopifnot(identical(Find(is.unsorted, x), x[[pos1]])) pos2 <- Position(is.unsorted, x, right=TRUE) stopifnot(identical(Find(is.unsorted, x, right=TRUE), x[[pos2]])) y <- x * 1000L Map("c", x, y)