I’m trying to write a let function that allows me to do things like:
let(a=2, b=3, a+b)
>>> 5
Currently I’m stuck with
let <- function(..., expr) {
with(list(...), quote(expr))
}
which doesn’t work at all. Any help appreciated.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here’s one way:
Edit: Alternatively, if you don’t want to have to name the expression-to-be-evaluated (i.e. passing it in via
expr), and if you are certain that it will always be the last argument, you could do something like this.