in reply to Re: Re: Fisher-Yates shuffle?
in thread Fisher-Yates shuffle?
Well, i suppose there are different answers. One could be speed. A "normal" swap of two variables (using a temp var and three assignments) is faster than list assignment. Another but better argument is maintainability. Consider that the cause of abigail-IIs concern about the LHS/RHS is that of trying to get the code to work without imposing a scoping block of some sort. Also, another effect of trying to get this to work on one line is that you used $a. Now most would tell you to avoid that and $b for various reasons. In your code it doesnt look like it would be a problem, but as the code morphs in the future, perhaps back to a multiline solution maybe that $a will not go away, and then maybe the code will morph so much that the trap im thinking off catches you (or your successor)
But one liners are fun I agree. :-)
Given Abigail's fix for it's failings, I'm happy to use it, with it's dependancy on subscript evaluation order on the basis that if this ever changes, it will break a lot of other code too, so the change should be well announced.
Actually I doubt it would be. Im pretty sure the assumption would be that no one in their right mind would depend on such an undocumented feature. (er, sorry :-)
Anyway, seya,
Yves / DeMerphq
---
Software Engineering is Programming when you can't. -- E. W. Dijkstra (RIP)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Fisher-Yates shuffle?
by BrowserUk (Patriarch) on Aug 09, 2002 at 22:43 UTC |