Open lo5 opened 2 years ago
> library(zeallot)
> box <- function(...){return(list(...))}
> view <- function(box,...){return(lapply(list(box,...),function(x){return(x$value)}))}
> c(first_name,last_name) %<-% view(box(title="First Name",value="Boaty"),box(title="Last Name",value="McBoaty"))
> first_name
[1] "Boaty"
> last_name
[1] "McBoaty"
Here is a solution.
So, roughly:
This goes into the library:
library(zeallot)
box <- function(...){return(list(...))}
view <- function(box,...){return(lapply(list(box,...),function(x){return(x$value)}))}
This is the userland:
c(first_name,last_name) %<-% view(box(title="First Name",value="Boaty"),box(title="Last Name",value="McBoaty"))
view(paste("Hello ", first_name, " ", last_name))
Thank you! That is wonderful.
What's the simplest, most ergonomic and idiomatic equivalent of the following Python code in R?
Source: https://nitro.h2o.ai/basics/#get-multiple-inputs-at-once
For context, this is what the above code would've looked like if Python didn't have destructuring assignments: