Anonymous user
Jensen's Device: Difference between revisions
→{{header|R}}
(omit from Go) |
|||
Line 570:
=={{header|R}}==
R uses a [[wp:Evaluation_strategy#Call_by_need|call by need]] evaluation strategy where function inputs
are evaluated on demand and then cached; functions can bypass the normal argument evaluation by using functions <tt>substitute</tt> and <tt>match.call</tt> to access the parse tree of the as-yet-unevaluated arguments, and using <tt>parent.frame</tt> to access the scope of the caller. There are some proposed
[http://developer.r-project.org/nonstandard-eval.pdf conventions] to do this in a way that is less confusing to the user
of a function
▲sum <- function(var, lo, hi, term) {
for (
.temp <- .temp + term
}
▲ s <- s + eval.parent(substitute(term))
}, as.list(match.call()[-1])),
enclos=parent.frame())
##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</lang>
=={{header|REXX}}==
|