File : Details

COMBINATIONS

COMBINES A N SIZE SET TO K SIZE SUBSETS
Details
Version
1.0
Author
JFER GIRJ
Maintainer
JFER GIRJ
Category
Supported Scilab Version
5.4
Creation Date
April 16, 2012
Description
```            //THIS FUNCTION COMBINES A N SIZE SET TO K SIZE SUBSETS
//WITH OR WITHOUT REPETITION
//JOSE-FERNANDO GIRALDO-J
//2012

//NOTICE THAT THIS FUNCTION IS RECURSIVE AND DOES NOT NEED TO CALCULATE
FACTORIALS

Use:

combine(set,size,repeat)

set: a column vector with elements to combine

size: integer. Defines the size of subsets

repeat: boolean. Defines if elements repetition is allowed in each combination

i.e:

elements=['dog';'cat';'bird';'mouse']

combinations=combine(elements,3,%F)

combinations  =

!dog  cat   bird     !
!                    !
!dog  cat   mouse    !
!                    !
!dog  bird  mouse    !
!                    !
!cat  bird  mouse    !

combinations=combine(elements,2,%T)

combinations  =

!dog    dog      !
!                !
!dog    cat      !
!                !
!dog    bird     !
!                !
!dog    mouse    !
!                !
!cat    cat      !
!                !
!cat    bird     !
!                !
!cat    mouse    !
!                !
!bird   bird     !
!                !
!bird   mouse    !
!                !
!mouse  mouse    !            ```
Files (1)
[1.24 kB]
Miscellaneous file
```
```
News (0)
Comment from Samuel Gougeon -- April 17, 2012, 06:31:51 PM
```Hello,

This is the nchoosek() function discussed here:
http://bugzilla.scilab.org/show_bug.cgi?id=7589
and implemented there as _combine():
http://forge.scilab.org/index.php/p/specfun/

Still expecting it inside native Scilab...

Regards
Samuel Gougeon
```
Comment from JFER GIRJ -- April 17, 2012, 11:59:23 PM
```Hello SAMUEL

means this is not useful?

JF```
Comment from Samuel Gougeon -- July 9, 2012, 01:43:34 PM
```Hello JF,

My remark meant that now we are at least two to convince
the operational team to include into Scilab this "basic"
function available on most of scientific pocket calculators.
That is to say: That it is common, because it is useful.

Regards
Samuel
```
Comment from JFER GIRJ -- July 9, 2012, 02:58:40 PM
```Hello SAMUEL