Just to add on a bit, please note that the return is superfluous. If you write
this:
normalDensityFunction = function(x, Mean, Variance) {
# no "return" value given at all
(1/sqrt(2*pi*Variance))*exp(-(1/2)*((x - Mean)^2)/Variance)
}
normalDensityFunction(2,0,1)
...you get the
Sorry, I missed the operation-after-function call aspect of the OP question.
However, I think my policy of avoiding the return function as much as possible
serves as an effective antibugging strategy for this problem, in addition to
its other benefits.
--
Sent from my phone. Please excuse my
I stand corrected. I have been chided in the past for not explicitly returning
my output by someone claiming it is not best practices.
-Steve
On Mon, 2016-11-14 at 12:22 -0500, Duncan Murdoch wrote:
On 14/11/2016 11:26 AM, Wolf, Steven wrote:
Just to add on a bit, please note that the
On 14/11/2016 11:26 AM, Wolf, Steven wrote:
Just to add on a bit, please note that the return is superfluous. If
you write this:
normalDensityFunction = function(x, Mean, Variance) {
# no "return" value given at all
(1/sqrt(2*pi*Variance))*exp(-(1/2)*((x - Mean)^2)/Variance)
}
On 13/11/2016 9:42 PM, Jeff Newmiller wrote:
I find your response here inconsistent... either including `return` causes a
"wasted" function call to occur (same result achieved slower) or the parser has
an optimization in it to prevent the wasted function call (only behaviorally the same).
I
I find your response here inconsistent... either including `return` causes a
"wasted" function call to occur (same result achieved slower) or the parser has
an optimization in it to prevent the wasted function call (only behaviorally
the same).
I carefully avoid using the return function in R.
On 13/11/2016 7:58 AM, Duncan Murdoch wrote:
On 13/11/2016 6:47 AM, Duncan Murdoch wrote:
On 13/11/2016 12:50 AM, Dave DeBarr wrote:
I've noticed that if I don't include parentheses around the intended return
value for the "return" statement, R will assume the first parenthetical
expression is
On 13/11/2016 6:47 AM, Duncan Murdoch wrote:
On 13/11/2016 12:50 AM, Dave DeBarr wrote:
I've noticed that if I don't include parentheses around the intended return
value for the "return" statement, R will assume the first parenthetical
expression is the intended return value ... even if that
On 13/11/2016 12:50 AM, Dave DeBarr wrote:
I've noticed that if I don't include parentheses around the intended return
value for the "return" statement, R will assume the first parenthetical
expression is the intended return value ... even if that parenthetical
expression is only part of a
I've noticed that if I don't include parentheses around the intended return
value for the "return" statement, R will assume the first parenthetical
expression is the intended return value ... even if that parenthetical
expression is only part of a larger expression.
Is this intentional?
I'm
10 matches
Mail list logo