implicit return? [🇷 for BE/BA]
Hi Hötzi,
Interestingly (at least to moi!), I tried out of curiosity to do this:
The benchmark for this version is much, much slower than any of the other proposals (at least on my system). Another example that shows that condensing code towards fewer keystrokes is not always fastest. I wonder what goes on internally since this is much slower? Perhaps space is allocated for both "foo" and "bar" in memory and then there is a decision as to which one to throw away and which one to keep on the CPU stack? I don't have a very good at understanding of these things.
This one is appearing even worse:
I have no idea why QWERTY2 would not outperform QWERTY or at least be the same if R has a kind of optimiser in the interpreter. Would you happen know????
Interestingly (at least to moi!), I tried out of curiosity to do this:
QWERTY=function(x)
{
ifelse ((x==0), "foo", "bar")
}
The benchmark for this version is much, much slower than any of the other proposals (at least on my system). Another example that shows that condensing code towards fewer keystrokes is not always fastest. I wonder what goes on internally since this is much slower? Perhaps space is allocated for both "foo" and "bar" in memory and then there is a decision as to which one to throw away and which one to keep on the CPU stack? I don't have a very good at understanding of these things.
This one is appearing even worse:
QWERTY2=function(x)
{
ifelse (x, "bar", "foo")
}
I have no idea why QWERTY2 would not outperform QWERTY or at least be the same if R has a kind of optimiser in the interpreter. Would you happen know????
—
Pass or fail!
ElMaestro
Pass or fail!
ElMaestro
Complete thread:
- R Inferno Helmut 2019-04-26 16:03 [🇷 for BE/BA]
- full conditions! mittyri 2019-04-26 16:20
- full conditions! Helmut 2019-04-26 16:41
- full conditions! d_labes 2019-04-27 14:29
- magik of R implicit return mittyri 2019-04-27 22:23
- magik of R implicit return ElMaestro 2019-04-27 22:34
- implicit return? d_labes 2019-04-28 19:36
- implicit return? ElMaestro 2019-04-28 20:36
- implicit return? Helmut 2019-04-28 20:50
- implicit return? ElMaestro 2019-04-28 21:16
- implicit return? Helmut 2019-04-28 23:38
- implicit return?ElMaestro 2019-04-29 09:40
- implicit return? Helmut 2019-04-29 10:41
- implicit return? ElMaestro 2019-04-29 12:55
- built-in ifelse mittyri 2019-04-30 13:05
- implicit return? ElMaestro 2019-04-29 12:55
- implicit return? Helmut 2019-04-29 10:41
- implicit return?ElMaestro 2019-04-29 09:40
- implicit return? Helmut 2019-04-28 23:38
- implicit return? ElMaestro 2019-04-28 21:16
- implicit return? d_labes 2019-04-28 19:36
- magik of R implicit return ElMaestro 2019-04-27 22:34
- magik of R implicit return mittyri 2019-04-27 22:23
- full conditions! mittyri 2019-04-26 16:20