Displaying 2 results from an estimated 2 matches for "crazy_notworking_fun".
2023 Mar 11
1
Multiple Assignment built into the R Interpreter?
...turning a list? This doesn't really fix the problem either though
Because a single list of length > 1 *is a valid thing to return from an R
function*. I think, like in Julia, you'd need to declare the set of things
being returned, and perhaps map them to the variables you want assigned
crazy_notworking_fun <- function() {
return(a = 5, b = 65, c = 275)
}
[a_val = a, b_val = b] <- crazy_notworking_fun()
Or even,
[a_val <- a, b_val <-b] <- crazy_notworking_fun()
In that case, however, it becomes somewhat unclear (to me at least) what
only_val <- crazy_notworking_fun()
would d...
2023 Mar 11
3
Multiple Assignment built into the R Interpreter?
Thanks Duncan and Ivan for the careful thoughts. I'm not sure I can follow
all aspects you raised, but to give my limited take on a few:
> your proposal violates a very basic property of the language, i.e. that all statements are expressions and have a value.
> What's the value of 1 + (A, C = init_matrices()).
I'm not sure I see the point here. I evaluated 1 + (d =