funprog-methods {IRanges}R Documentation

Functional programming methods for List objects

Description

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.

Usage

## 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_)

Arguments

f, init, right, accumulate, nomatch

See ?base::Reduce for a description of these arguments.

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.)

Author(s)

P. Aboyoun

See Also

Examples

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)

[Package IRanges version 1.22.9 Index]