Talk:Knuth shuffle

From Rosetta Code

Duplicate

Note: this is a sub-task of Playing Cards. --IanOsgood 01:11, 20 May 2009 (UTC)

Well one motivation for this was to have another task other than Knapsack that began with the letter K, also this task is for integers, whereas the Playing Cards task is for strings (or whatever datatype you choose to implement cards).

But they do overlap...perhaps code from this task could be used in Playing Cards? This task could be made generic I suppose. Whatever everyone else things. *shrugs* --Mbishop 04:42, 20 May 2009 (UTC)

I feel for you over the K task thing!
I had even more trouble over tasks beginning with Y :-) --Paddy3118 06:10, 20 May 2009 (UTC)

It's also effectively a subtask of Bogosort. —Dkf 10:01, 20 May 2009 (UTC)

BASIC Integer Array?

The BASIC example I just entered doesn't do an integer array; instead, it's code I wrote specifically for shuffling cards. (shrug) I would've put it under the Playing Cards page, but it's just too simplistic, and I didn't feel like dumbing it down any further. (I wrote it to show someone else how to shuffle several ago.) -- Eriksiers 01:25, 11 August 2009 (UTC)

Would you try and make the code work with integers? It makes it hard to compare entries otherwise. Thanks.--Paddy3118 06:20, 11 August 2009 (UTC)
Sorry, didn't think of that. Done. -- Eriksiers 14:44, 11 August 2009 (UTC)

F#

I just happened to notice the F# entry starts off with open System twice. Seems a bit odd to me, but I don't know anything about F# -- it just looks weird to me. Is this right? -- Eriksiers 22:18, 24 December 2009 (UTC)

Anybody? Anybody? Bueller? Bueller? -- Eriksiers 18:59, 15 January 2010 (UTC)
Good question. I know zilch about F# as well. -- Rldrenth 04:02, 16 January 2010 (UTC)

C#

The C# code had a serious problem in its implementation. It selected a random position from the *entire* array on each loop. This is a serious problem as it leads to a non-uniform distribution of outcomes, thereby ruining the purpose of the algorithm. Wikipedia has a nice description of the problem here.

C++

The C++ example shows std::random_shuffle; however, std::random_shuffle is deprecated in C++14 (and removed in C++17) in preference to std::shuffle. The conundrum is that std::shuffle isn't available until C++11, since it uses the new random number generation facilities that arrived with C++11. In general, std::random_shuffle and std::shuffle is a bit of a mess.

Does Rosetta Code need a pre-C++11 and post-C++11 language? So many things have changed with the latest standards, and C++ is now actually a moving target. (Reference: http://en.cppreference.com/w/cpp/algorithm/random_shuffle ) --Intvnut (talk) 06:36, 3 June 2015 (UTC)

Standards change things in a lot of languages. If there is still a lot of users of an old standard and an example would be significantly different between standards then you could show them both - or '#ifdef ...' to accommodate both, or just add a comment stating what the change would be. Whatever is neatest. --Paddy3118 (talk) 06:57, 3 June 2015 (UTC)

Haskell

The haskell example doesn't run under GHC 7.8.3 and prints the following errors: knuthshuffle.hs:9:39: Not in scope: ‘l’

knuthshuffle.hs:9:47: Not in scope: ‘x’

This has been fixed, code now compiles and works as intended (GHC 7.8.4).


Formulae hidden to most browsers after under-tested edits at 09:03, 5 September 2016

Some under-tested task description edits made to the task page at 09:03, 5 September 2016, particularly involving the use of <math> tags, have left some elements of the task description formulae invisible to all browsers which display the graphic file version of formulae rather than processing the MathML (this is, in fact, the majority of browsers). The MediaWiki processor does not currently expect such spaces, and generates syntactically ill-formed HTML if they are introduced. Other aspects of these edits may further compound the problem. Hout (talk) 20:59, 22 September 2016 (UTC)

Repaired - pseudocode expressions should now be fully visible in all browsers Hout (talk) 20:14, 15 November 2016 (UTC)