04-25-2018 06:58 AM
@Mitch_Peplow wrote:
So when I asked the question of if you take the value of 6 and decrement by 2 every time, is that not possible with a Factorial?
You can decrement by 2, but it will not meet the definition of a factorial.
04-25-2018 09:33 AM
wiebe@CARYA wrote:
Note that the implementation is old-school (=OBSOLETE).
Nowadays we can simply put the VI (as a sub VI) on the diagram. Much, much, better.
Ah, yes, many recursive functions can be written iteratively, but for others, the recursive method is quicker, "neater", and easier to understand. For example, the formula for Binomial Coefficients (or the number of ways to choose k things from n objects) involves lots of multiplication and division when done without recursion, but only addition with recursion. It is also remarkably fast -- the number of 5 card poker hands (2.6 million) takes about half a second, 6-card hands (20 million) takes 4.6 seconds, and 7-card hands (134 million) takes under 29 seconds. I don't have the patience to compute the number of bridge hands (13 cards) ...
Bob Schor
04-25-2018 10:07 AM
@Bob_Schor wrote:
wiebe@CARYA wrote:
Note that the implementation is old-school (=OBSOLETE).
Nowadays we can simply put the VI (as a sub VI) on the diagram. Much, much, better.
Ah, yes, many recursive functions can be written iteratively, but for others, the recursive method is quicker, "neater", and easier to understand. For example, the formula for Binomial Coefficients (or the number of ways to choose k things from n objects) involves lots of multiplication and division when done without recursion, but only addition with recursion. It is also remarkably fast -- the number of 5 card poker hands (2.6 million) takes about half a second, 6-card hands (20 million) takes 4.6 seconds, and 7-card hands (134 million) takes under 29 seconds. I don't have the patience to compute the number of bridge hands (13 cards) ...
Bob Schor
How about double-pinochle with 20 cards and four decks of face cards plus 10 and A?
04-26-2018 03:12 AM
@Bob_Schor wrote:
wiebe@CARYA wrote:
Note that the implementation is old-school (=OBSOLETE).
Nowadays we can simply put the VI (as a sub VI) on the diagram. Much, much, better.
Ah, yes, many recursive functions can be written iteratively, but for others, the recursive method is quicker, "neater", and easier to understand. For example, the formula for Binomial Coefficients (or the number of ways to choose k things from n objects) involves lots of multiplication and division when done without recursion, but only addition with recursion. It is also remarkably fast -- the number of 5 card poker hands (2.6 million) takes about half a second, 6-card hands (20 million) takes 4.6 seconds, and 7-card hands (134 million) takes under 29 seconds. I don't have the patience to compute the number of bridge hands (13 cards) ...
Bob Schor
I'm not talking about iterative recursion ("fake" recursion). That has always been an option, but can result in more complex vs. more complex concept. I usually prefer recursive VI's as well.
I was saying the dynamic call by reference can be replaced with a call to the same VI:
04-26-2018 09:00 AM
@Wiebe -- I completely mis-interpreted your remark ("OBSOLETE"). I was thinking "recursion" (= reentrant VI) and didn't realize I hadn't mentioned the word earlier, and thought that you were saying that the recursive method was obsolete!
This may be due to a similar post around the same time asking about Fibonacci Numbers, which also have a Recursive Definition, and I had "recursion" on the brain (or what passes for a brain). I completely agree with your FactorX method of computing X!, though I might have made the Default case return "1" and the other case be 1.. (to foil being called with negative numbers).
Bob Schor
04-26-2018 09:40 AM
@Bob_Schor wrote:
@Wiebe -- I completely mis-interpreted your remark ("OBSOLETE"). I was thinking "recursion" (= reentrant VI) and didn't realize I hadn't mentioned the word earlier, and thought that you were saying that the recursive method was obsolete!
That happens. It was clear to me it was just miscommunication. Just made the example so others can learn. We really don't want people to take those exam questions as an example.
@Bob_Schor wrote:
This may be due to a similar post around the same time asking about Fibonacci Numbers, which also have a Recursive Definition, and I had "recursion" on the brain (or what passes for a brain). I completely agree with your FactorX method of computing X!, though I might have made the Default case return "1" and the other case be 1.. (to foil being called with negative numbers).
The default and 1.. cases makes good sense.
Didn't think the factor vi through, I did not even run it before posting! Just remade the VI from the image.
03-18-2019 02:34 PM
What would be the output if the VI was not re entrant? Would it be 12?
03-19-2019 04:12 AM
@proph wrote:
What would be the output if the VI was not re entrant? Would it be 12?
If it wasn't reentrant, it wouldn't compile (or run)… A non-reentrant VI can't call itself.
03-19-2019 06:16 AM
@Mitch_Peplow wrote:
So when I asked the question of if you take the value of 6 and decrement by 2 every time, is that not possible with a Factorial? So basically is it always a decrement of one every time, so it will always be 6x5x4x3x2x1 and nothing else?
Wouldn't that be 3!*2?
6*4*2 = 3*2 * 2*2 * 1*2 = (3*2*1)*2 = 3!*2
/Y
03-19-2019 07:25 AM
Wouldn't that be 3!*2?6*4*2 = 3*2 * 2*2 * 1*2 = (3*2*1)*2 = 3!*2
Oops, nope.
6*4*2 = 48
(3!) * 2 = 12
Looks like you were applying the Distributive law to multiplication by accident....
-Kevin P