anuary 05, 2012 10:38 AM
> To: r-help@r-project.org; Tom Roche
> Subject: Re: [R] [newbie] stack operations, or functions with side effects
> (or both)
>
> On 01/05/2012 09:18 AM, Tom Roche wrote:
> >
> > William Dunlap Wed, 4 Jan 2012 22:54:41 +
> >> R functio
On 01/05/2012 09:18 AM, Tom Roche wrote:
William Dunlap Wed, 4 Jan 2012 22:54:41 +
R functions [can] use their enclosing environments to save state.
Aha!
makeStack<- function () {
stack<- list()
list(pop = function() {
if (length(stack) == 0) { # get from an enclosing env.
William Dunlap Wed, 4 Jan 2012 22:54:41 +
> R functions [can] use their enclosing environments to save state.
Aha!
> makeStack <- function () {
> stack <- list()
> list(pop = function() {
> if (length(stack) == 0) { # get from an enclosing env.
> retval <- NULL
> } else {
>
There is a crude implementation of
stacks in 'S Poetry' (available on
www.burns-stat.com). I haven't looked
at it, but I'd guess that code would
work in R as well.
On 04/01/2012 21:22, Tom Roche wrote:
summary: Specifically, how does one do stack/FIFO operations in R?
Generally, how does one c
ot;
There are various encapsulations of this method in R.
See, e.g., "reference classes" or the "proto" package.
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] O
do s[1] and s[-1] do what you're looking for?
those are just to display... if you want to change s, you need to reassign
it or fiddle with namespacing. however, I'd say it is better to write R
code as though data structures are immutable until you explicitly re-assign
them rather than trying to de
summary: Specifically, how does one do stack/FIFO operations in R?
Generally, how does one code functions with side effects in R?
details:
I have been a coder for years, mostly using C-like semantics (e.g.,
Java). I am now trying to become a scientist, and to use R, but I don't
yet have the sens
7 matches
Mail list logo