## Examples
patrn <- c(1,2,3,4)
exmpl <- c(3,3,4,2,3,1,2,3,4,8,8,23,1,2,3,4,4,34,4,3,2,1,1,2,3,4)
occurs(patrn, exmpl)
## [1] 6 13 23
if (FALSE) {
set.seed(2437)
p <- sample(1:20, 1000000, replace=TRUE)
system.time(i <- occurs(c(1,2,3,4,5), p)) #=> [1] 799536
## user system elapsed
## 0.017 0.000 0.017 [sec]
system.time(c <- count(p))
## user system elapsed
## 0.075 0.000 0.076
print(c)
## $v
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## $e
## [1] 49904 50216 49913 50154 49967 50045 49747 49883 49851 49893
## [11] 50193 50024 49946 49828 50319 50279 50019 49990 49839 49990
}
Run the code above in your browser using DataLab