Translated findEmptyPop
This commit is contained in:
parent
03bec3b4b4
commit
e31dec2786
1 changed files with 12 additions and 0 deletions
12
R/findEmptyPop.R
Normal file
12
R/findEmptyPop.R
Normal 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))
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue