inst/examples/ireadBinExample.R

# This is a terrible example and desperately needs to be replaced
# with something that appears somewhat useful.

library(itertools)
library(foreach)

n <- 1000
zz <- file("testbin", "wb")
expected <- foreach(1:1000) %do% {
  x <- rnorm(n)
  writeBin(x, zz)
  mean(x)
}
close(zz)

it <- ireadBin("testbin", "double", n=n)
actual <- foreach(x=it) %do% {
  mean(x)
}

print(identical(actual, expected))

unlink("testbin")

Try the itertools package in your browser

Any scripts or data that you put into this service are public.

itertools documentation built on May 2, 2019, 6:16 p.m.