From f52fe4e09157a4ea13ba968f89956e22ec079802 Mon Sep 17 00:00:00 2001 From: Laurent Franckx Date: Thu, 29 Jan 2015 23:23:20 +0100 Subject: [PATCH] Update Alathea_Expressions.md --- 10_Expressions/Alathea_Expressions.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/10_Expressions/Alathea_Expressions.md b/10_Expressions/Alathea_Expressions.md index c8bce83..5f15e67 100644 --- a/10_Expressions/Alathea_Expressions.md +++ b/10_Expressions/Alathea_Expressions.md @@ -82,6 +82,17 @@ concat(quote(f), a = 1, b = quote(mean(a))) #> f(a = 1, b = mean(a)) ``` +Possible solution: + +```r +concat <- function(what, a, b){ + as.call(list(what, substitute({a = a_arg}, list(a_arg = a))[[2]], substitute({b = b_arg}, list(b_arg = b))[[2]])) +} + +concat(quote(f), a = 1, b = quote(mean(a))) +``` + + ### Since list()s don’t belong in expressions, we could create a more convenient call constructor that automatically combines lists into the arguments. Implement make_call() so that the following code works.