Displaying 7 results from an estimated 7 matches for "somehow_get_last_env_of_f".
2023 Jan 12
4
return value of {....}
...iple statements into one.
Now think about a statement like this
f <- function(n) {
x <- runif(n)
x**2
}
Then we can do
y <- f(10)
Now, you suggested way would look like this:
f <- function(n) {
x <- runif(n)
y <- x**2
}
And we'd need to do something like:
f(10)
y <- somehow_get_last_env_of_f$y
So having a compound statement evaluate to a value clearly has a benefit.
Best Regards,
Valentin
09.01.2023 18:05:58 akshay kulkarni <akshay_e4 at hotmail.com>:
> Dear Valentin,
> ? ? ? ? ? ? ? ? ? ? ? ? ? But why should {....} "return" a value? It could just as well eva...
2023 Jan 13
1
return value of {....}
...gt; x <- runif(n)
> x**2
> }
>
> Then we can do
>
> y <- f(10)
>
> Now, you suggested way would look like this:
>
> f <- function(n) {
> x <- runif(n)
> y <- x**2
> }
>
> And we'd need to do something like:
>
> f(10)
> y <- somehow_get_last_env_of_f$y
>
> So having a compound statement evaluate to a value clearly has a benefit.
>
> Best Regards,
> Valentin
>
> 09.01.2023 18:05:58 akshay kulkarni <akshay_e4 at hotmail.com>:
>
> > Dear Valentin,
> > But why should {....} "r...
2023 Jan 15
3
return value of {....}
...gt; x <- runif(n)
> x**2
> }
>
> Then we can do
>
> y <- f(10)
>
> Now, you suggested way would look like this:
>
> f <- function(n) {
> x <- runif(n)
> y <- x**2
> }
>
> And we'd need to do something like:
>
> f(10)
> y <- somehow_get_last_env_of_f$y
>
> So having a compound statement evaluate to a value clearly has a benefit.
>
> Best Regards,
> Valentin
>
> 09.01.2023 18:05:58 akshay kulkarni <akshay_e4 at hotmail.com>:
>
> > Dear Valentin,
> > But why should {....} "r...
2023 Jan 16
1
return value of {....}
...gt; x <- runif(n)
> x**2
> }
>
> Then we can do
>
> y <- f(10)
>
> Now, you suggested way would look like this:
>
> f <- function(n) {
> x <- runif(n)
> y <- x**2
> }
>
> And we'd need to do something like:
>
> f(10)
> y <- somehow_get_last_env_of_f$y
>
> So having a compound statement evaluate to a value clearly has a benefit.
>
> Best Regards,
> Valentin
>
> 09.01.2023 18:05:58 akshay kulkarni <akshay_e4 at hotmail.com>:
>
> > Dear Valentin,
> > But why should {....} "r...
2023 Jan 16
2
return value of {....}
...gt; x <- runif(n)
> x**2
> }
>
> Then we can do
>
> y <- f(10)
>
> Now, you suggested way would look like this:
>
> f <- function(n) {
> x <- runif(n)
> y <- x**2
> }
>
> And we'd need to do something like:
>
> f(10)
> y <- somehow_get_last_env_of_f$y
>
> So having a compound statement evaluate to a value clearly has a benefit.
>
> Best Regards,
> Valentin
>
> 09.01.2023 18:05:58 akshay kulkarni <akshay_e4 at hotmail.com>:
>
> > Dear Valentin,
> > But why should {....} "r...
2023 Jan 09
3
return value of {....}
Dear Valentin,
But why should {....} "return" a value? It could just as well evaluate all the expressions and store the resulting objects in whatever environment the interpreter chooses, and then it would be left to the user to manipulate any object he chooses. Don't you think returning the last, or any value, is redundant? We are living in the 21st century
2023 Jan 16
1
return value of {....}
...gt; x <- runif(n)
> x**2
> }
>
> Then we can do
>
> y <- f(10)
>
> Now, you suggested way would look like this:
>
> f <- function(n) {
> x <- runif(n)
> y <- x**2
> }
>
> And we'd need to do something like:
>
> f(10)
> y <- somehow_get_last_env_of_f$y
>
> So having a compound statement evaluate to a value clearly has a benefit.
>
> Best Regards,
> Valentin
>
> 09.01.2023 18:05:58 akshay kulkarni <akshay_e4 at hotmail.com>:
>
> > Dear Valentin,
> > But why should {....} "r...