Best shuffle: Difference between revisions
Content added Content deleted
(→{{header|Haskell}}: Changed to correct and efficient solution) |
|||
Line 1,589: | Line 1,589: | ||
The core of the algorithm is swapping procedure similar to those implemented in AWK and Icon examples. It could be done by a pure program with use of immutable vectors (though it is possible to use mutable vectors living in <tt>ST</tt> or <tt>IO</tt>, but it won't make the program more clear). |
The core of the algorithm is swapping procedure similar to those implemented in AWK and Icon examples. It could be done by a pure program with use of immutable vectors (though it is possible to use mutable vectors living in <tt>ST</tt> or <tt>IO</tt>, but it won't make the program more clear). |
||
<lang Haskell>import Data.Vector ((//),(!) |
<lang Haskell>import Data.Vector ((//), (!)) |
||
import qualified Data.Vector as V |
import qualified Data.Vector as V |
||
import Data.List (delete, find) |
import Data.List (delete, find) |
||
Line 1,648: | Line 1,648: | ||
"Rosetta Code is a programming chrestomathy site." " Rmoisnegt tcahmrCeosdteo miast hay psriotger.a" 0</pre> |
"Rosetta Code is a programming chrestomathy site." " Rmoisnegt tcahmrCeosdteo miast hay psriotger.a" 0</pre> |
||
That's much better. |
That's much better. |
||
=== Nondeterministic List-based solution === |
=== Nondeterministic List-based solution === |