MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Combinatorica, NthPermutation, and a Sort behavior

  • To: mathgroup at
  • Subject: [mg50147] Combinatorica, NthPermutation, and a Sort behavior
  • From: Steve Gray <stevebg at>
  • Date: Tue, 17 Aug 2004 05:01:37 -0400 (EDT)
  • References: <cfkaj9$fa0$>
  • Sender: owner-wri-mathgroup at

	Dr. Bob is right, as usual. Apparently the function NthPermutation has been changed, and I
quote from his answer which quotes from Wolfram:

 NthPermutation::usage = "NthPermutation[n, l] gives the nth lexicographic permutation of list l.
This function is obsolete; use UnrankPermutation instead."

Therefore, try UnrankPermutation[n,list]. For example,

UnrankPermutation[20, {a, b, c, d, e, f}] 
{a, b, f, d, c, e}

	Incidentally, I found something interesting with Sort, which experienced users might
anticipate. I computed a list containing answers in the "exact" format including many square roots,
arithmetic operators, etc.. This does NOT sort the same way that actual numerics would, since the
lexical order is not the numeric order.

>My Combinatorica.m is in
>but neither
><< DiscreteMath`Combinatorica`
>apparently loads it because NthPermutation[100,{a,b,c,d,e,f,g}] just echoes NthPermutation.
>My $Path is
>{ D:\Program Files\Wolfram Research\Mathematica\5.0\AddOns\JLink, 
>  D:\Program Files\Wolfram Research\Mathematica\5.0\AddOns\NETLink,
>  D:\Program Files\Wolfram Research\Mathematica\5.0\AddOns\StandardPackages\StartUp,   
>  D:\Program Files\Wolfram Research\Mathematica\5.0\AddOns\StandardPackages\StartUp,
>  D:\Program Files\Wolfram Research\Mathematica\5.0\AddOns\Autoload,
>  D:\Program Files\Wolfram Research\Mathematica\5.0\AddOns\Applications,
>  D:\Program Files\Wolfram Research\Mathematica\5.0\AddOns\ExtraPackages,
>  D:\Program Files\Wolfram Research\Mathematica\5.0\SystemFiles\Graphics\Packages,
>  D:\Program Files\Wolfram Research\Mathematica\5.0\Configuration\Kernel  }
>(plus some other stuff)
>   How do I put the required path into $Path, and I wonder why wasn't it included in the package I
>received? I changed nothing about Path.
>   Thanks for any info. This will be holding me up.
>Steve Gray

  • Prev by Date: Re: Smalest enclosing circle
  • Next by Date: Re: Help: piecewise functions
  • Previous by thread: Re: Re: Re: Re: Re: Re: FindMinimum and the minimum-radius circle
  • Next by thread: can this be solved in Mathematica 5.0?