[Previous] [Next] [Contents]

[ImplState=stable,TestState=stable,DocState=deprecated]

combinat::permute -- permutations of a list (deprecated)

Introduction

combinat::permute(list) computes all the reorderings of the given list list.

combinat::permute(n) computes all the reorderings of the list [1,2,...,n].

Call(s)


combinat::permute(n)
combinat::permute(list)
combinat::permute(list,Duplicate)

Parameters

n- a nonnegative integer
list- a list

Options

Duplicate- The result may contain identical lists if there are duplicates in the given list list.

Returns

A list of type DOM_LIST containing every reordered list as an element.

Details

Option: Duplicate

Example 1

There are exactly two ways of ordering two elements:

>> combinat::warnDeprecated(FALSE):
   combinat::permute([a,b]) 
     
                             [[a, b], [b, a]]
        

The function combinat::permute is deprecated:

>> old_val:=combinat::warnDeprecated(TRUE):
   combinat::permute([a,b]);
   combinat::warnDeprecated(old_val):
     
      Warning: combinat::permute(l) is obsolete.
      Please use 'combinat::permutations::list(l)' instead. [combina\
      t::permute]
      
                             [[a, b], [b, a]]
        

Here is the recommended replacement:

>> combinat::permutations::list([a,b])
     
                             [[a, b], [b, a]]
        

Example 2

An integer argument n is equivalent to the list of the first n integers.

>> combinat::permute(3) 
     
      [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2],
      
         [3, 2, 1]]
        

Here is the recommended replacement:

>> combinat::permutations::list(3)
     
      [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2],
      
         [3, 2, 1]]
        

Example 3

By default, one gets all distinct reorderings.

>> combinat::permute([a,a,b]) 
     
                     [[a, a, b], [a, b, a], [b, a, a]]
        

Here is the recommended replacement:

>> combinat::permutations::list([a,a,b])
     
                     [[a, a, b], [a, b, a], [b, a, a]]
        

Example 4

But if one wants to get a list with duplicated reordered entries, this is also possible.

>> combinat::permute([a,a,b],Duplicate) 
     
      [[a, a, b], [a, b, a], [a, a, b], [a, b, a], [b, a, a],
      
         [b, a, a]]
        

Here is the recommended replacement:

>> combinat::permutations::list([a,a,b], Duplicate)
     
      [[a, a, b], [a, b, a], [a, a, b], [a, b, a], [b, a, a],
      
         [b, a, a]]
        

Example 5

Sets are not allowed as an argument.

>> combinat::permute({3,4}) 
     
      Error: Wrong type of 1. argument (type 'Type::Union(Type::NonN\
      egInt, DOM_LIST)' expected,
             got argument '{3, 4}');
      during evaluation of 'combinat::permute'
        

[Previous] [Next] [Contents]


MuPAD Combinat, an open source algebraic combinatorics package