Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
15
Task/Jensens-Device/R/jensens-device.r
Normal file
15
Task/Jensens-Device/R/jensens-device.r
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
sum <- function(var, lo, hi, term)
|
||||
eval(substitute({
|
||||
.temp <- 0;
|
||||
for (var in lo:hi) {
|
||||
.temp <- .temp + term
|
||||
}
|
||||
.temp
|
||||
}, as.list(match.call()[-1])),
|
||||
enclos=parent.frame())
|
||||
|
||||
sum(i, 1, 100, 1/i) #prints 5.187378
|
||||
|
||||
##and because of enclos=parent.frame(), the term can involve variables in the caller's scope:
|
||||
x <- -1
|
||||
sum(i, 1, 100, i^x) #5.187378
|
||||
Loading…
Add table
Add a link
Reference in a new issue