Translated findEmptyPop

This commit is contained in:
Waldir Leoncio 2020-11-09 08:33:02 +01:00
parent 03bec3b4b4
commit e31dec2786

12
R/findEmptyPop.R Normal file
View file

@ -0,0 +1,12 @@
findEmptyPop <- function(npops) {
# % Palauttaa ensimm<6D>isen tyhj<68>n populaation indeksin. Jos tyhji<6A>
# % populaatioita ei ole, palauttaa -1:n.
pops <- t(unique(PARTITION))
if (length(pops) == npops) {
emptyPop <- -1
} else {
popDiff <- diff(c(0, pops, npops + 1))
emptyPop <- min(find(popDiff > 1))
}
return(list(emptyPop = emptyPop, pops = pops))
}