Skip to content

Commit 0eb406b

Browse files
committed
Small corrections
1 parent 7cddefc commit 0eb406b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

mathics/packages/DiscreteMath/CombinatoricaV0.9.m

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
(* :Title: Combinatorica
32
*)
43
(* :Author:
@@ -629,7 +628,7 @@
629628
RankPermutation[ Map[(If[#>p[[1]], #-1, #])&, Rest[p]] ]
630629

631630
NthPermutation[n1_Integer,l_List] :=
632-
Module[{k, n=n1, s=l, i},
631+
Block[{k, n=n1, s=l, i},
633632
Table[
634633
n = Mod[n,(i+1)!];
635634
k = s [[Quotient[n,i!]+1]];
@@ -644,6 +643,12 @@
644643

645644
(* Section 1.1.3 RandomPermutations, Pages 6-7 *)
646645

646+
(*** FIXME:
647+
ListPlot[ RandomPermutation1[30]]
648+
shows that RandomPermutaiton1 isn't good. Therefore we use RandomPermutation2
649+
for RandomPermutation.
650+
****)
651+
647652
RandomPermutation1[n_Integer?Positive] :=
648653
Map[ Last, Sort[ Map[({RandomInteger[],#})&,Range[n]] ] ]
649654

@@ -657,7 +662,8 @@
657662
p
658663
]
659664

660-
RandomPermutation[n_Integer?Positive] := RandomPermutation1[n]
665+
(* rocky: RandomPermutation1 not random, so use RandomPermutation2 *)
666+
RandomPermutation[n_Integer?Positive] := RandomPermutation2[n]
661667

662668
(* Section 1.1.4 Permutation from Transpostions, Page 11 *)
663669
MinimumChangePermutations[l_List] :=

0 commit comments

Comments
 (0)