Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

makeIwrapper

Iterator Maker Generator


Description

The makeIwrapper function makes iterator makers. The resulting iterator makers all take an optional count argument which specifies the number of times the resulting iterator should fire. The iterators are wrappers around functions that return different values each time they are called. The isample function is an example of one such iterator maker (as are irnorm, irunif, etc.).

Usage

makeIwrapper(FUN)
isample(..., count)

Arguments

FUN

a character string naming a function that generates different values each time it is called; typically one of the standard random number generator functions.

count

number of times that the iterator will fire. If not specified, it will fire values forever.

...

arguments to pass to the underlying FUN function.

Value

An iterator that is a wrapper around the corresponding function.

Examples

# create an iterator maker for the sample function
  mysample <- makeIwrapper('sample')
  # use this iterator maker to generate an iterator
  # that will generate three five member samples from the
  # sequence 1:100
  it <- mysample(1:100, 5, count=3)
  nextElem(it)
  nextElem(it)
  nextElem(it)
  try(nextElem(it))  # expect a StopIteration exception

iterators

Provides Iterator Construct

v1.0.13
Apache License (== 2.0)
Authors
Michelle Wallig [cre], Revolution Analytics [aut, cph], Steve Weston [aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.