//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 !