Debian Codegraph @

man/funEnv.Rd

raw
1 \name{funEnv}
2 \alias{funEnv}
3 \title{List-like Environment of Functions (and More)}
4 \description{
5 Construct a \dQuote{list}, really an \code{\link{environment}}
6 typically of functions and optionally other \R objects, where the
7 \code{\link{function}}s and \code{\link{formula}}s all
8 all share the same environment.
9 Consequently, the functions may call each other.
10
11 On technical level, this is just a simple wrapper around
12 \code{\link{list2env}()}.
13 }
14 \usage{
15 funEnv(..., envir = NULL, parent = parent.frame(),
16 hash = (...length() > 100), size = max(29L, ...length()))
17 }
18 \arguments{
19 \item{...}{an arbitrary \emph{named} \dQuote{list} of \R objects,
20 typically including several \code{\link{function}}s.}
21 \item{envir}{an \code{\link{environment}} or \code{NULL}.}
22 \item{parent}{(for the case \code{envir = NULL}): a parent frame aka
23 enclosing environment, see \code{\link{new.env}} and \code{\link{list2env}}.}
24 \item{hash, size}{(for the case \code{envir = NULL}): \code{hash} a
25 logical indicating if the created environment should use hashing,
26 and (\code{size}) the hash size, see \code{\link{list2env}}.}
27 }
28 \value{
29 an \code{\link{environment}}, say \code{E}, containing the objects
30 from \code{...} (plus those in \code{envir}), and all function
31 objects' \code{\link{environment}()} is E.
32 }
33 %% \references{
34 %% }
35 \author{Martin Maechler}
36
37 \seealso{
38 \code{\link{list2env}}, \code{\link{environment}}
39 }
40 \examples{
41 ee <- funEnv(f = function(x) g(2*(x+1)),
42 g = function(y) hh(y+1),
43 hh = function(u) u^2,
44 info = "Some Information (not a function)")
45 ls(ee) # here the same as names(ee)
46 ## Check that it works: i.e., that "f sees g" and "g sees hh":
47 stopifnot(all.equal(ee$f(pi), (2*pi+3)^2))
48 ee$f(0:4) # [1] 9 25 49 81 121
49 }
50 \keyword{programming}
51 \keyword{data}