Re: [R] Question about expression parser for "return" statement

2016-11-14 Thread Wolf, Steven
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

Re: [R] Question about expression parser for "return" statement

2016-11-14 Thread Jeff Newmiller
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

Re: [R] Question about expression parser for "return" statement

2016-11-14 Thread Wolf, Steven
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

Re: [R] Question about expression parser for "return" statement

2016-11-14 Thread Duncan Murdoch
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) }

Re: [R] Question about expression parser for "return" statement

2016-11-14 Thread Duncan Murdoch
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

Re: [R] Question about expression parser for "return" statement

2016-11-13 Thread Jeff Newmiller
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.

Re: [R] Question about expression parser for "return" statement

2016-11-13 Thread Duncan Murdoch
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

Re: [R] Question about expression parser for "return" statement

2016-11-13 Thread Duncan Murdoch
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

Re: [R] Question about expression parser for "return" statement

2016-11-13 Thread Duncan Murdoch
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

[R] Question about expression parser for "return" statement

2016-11-13 Thread Dave DeBarr
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