lambdaR: Novel lambda expressions in R

> library(lambdaR)

バージョン: 2.0.1


関数名 概略
Filter_ Filter function for lambda expression
Find_ Find function for lambda expression
Map2_ Map function for lambda expression
Map2v_ Map function for lambda expression
Map_ Map function for lambda expression
Mapv_ Map function for lambda expression with unlisted output
Negate_ Negate function for lambda expression
Position_ Position function for lambda expression
Reduce_ Reduce function for lambda expression lambda Lambda function
lambdaR lambdaR

Filter_

> Filter_(1:10, x : x %% 2 == 0)
[1]  2  4  6  8 10
> 1:10 %>% Filter_(._ %% 2 == 0)
[1]  2  4  6  8 10

Find_

> LETTERS %>% Find_(x: tolower(x) == "f")
[1] "F"

Negate_

> 1:10 %>% Filter_(._ %% 2 == 0)
[1]  2  4  6  8 10
> 1:10 %>% Filter_(Negate_(x: x %% 2 == 0))
[1] 1 3 5 7 9

Map_

> 1:3 %>% Map_(x : x * 2)
[[1]]
[1] 2

[[2]]
[1] 4

[[3]]
[1] 6
> # ベクトルで出力
> 1:3 %>% Mapv_(x : x / 2)
[1] 0.5 1.0 1.5

Position_

> LETTERS %>% Position_(x: x == "F")
[1] 6

Reduce_

> # sum(1:10)
> 1:10 %>% Reduce_(x, y : x + y)
[1] 55

lambda

> # x: x + 1
> lambda(x: x + 1)(2:4)
[1] 3 4 5
> # lambda x,y: x + y
> lambda(x,y: x + y)(1, 2:4)
[1] 3 4 5