Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
10
Task/First-class-functions/R/first-class-functions-1.r
Normal file
10
Task/First-class-functions/R/first-class-functions-1.r
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
cube <- function(x) x^3
|
||||
croot <- function(x) x^(1/3)
|
||||
compose <- function(f, g) function(x){f(g(x))}
|
||||
|
||||
f1 <- c(sin, cos, cube)
|
||||
f2 <- c(asin, acos, croot)
|
||||
|
||||
for(i in 1:3) {
|
||||
print(compose(f1[[i]], f2[[i]])(.5))
|
||||
}
|
||||
1
Task/First-class-functions/R/first-class-functions-2.r
Normal file
1
Task/First-class-functions/R/first-class-functions-2.r
Normal file
|
|
@ -0,0 +1 @@
|
|||
sapply(mapply(compose,f1,f2),do.call,list(.5))
|
||||
Loading…
Add table
Add a link
Reference in a new issue