path: Compose all the function in a list

Description Usage Arguments Value Author(s) Examples

View source: R/path.R

Description

It applies the compose opertor recursively on all the elements of the list provided as argument

Usage

1
path(fs)

Arguments

fs

The list of the functions that must be composed together (e.g: list(f1, f2, f3, ...)).

Value

A function of the type g(x, ret) result of the pairwise composition of each element in the list.

Author(s)

Matteo Provenzano
http://www.alephdue.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# define a function that doubles its argument
times.two <- function(x, ret) {
  ret(x*2)
}

# define a function that loops over a list of list and double every element
loop <- forget(path(list(lapply, lapply, times.two)))

#returns list(list(2, 4, 6), list(8,10,12))
loop(list(list(1,2,3),list(4,5,6)))

matteoprovenzano/kriens-r documentation built on May 21, 2019, 12:59 p.m.