Displaying 2 results from an estimated 2 matches for "makestack".
Did you mean:
makesock
2012 Jan 04
3
[newbie] stack operations, or functions with side effects (or both)
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 sense of "good R" and R idiom (i.e., expressions that are
to R what (e.g.) the Schwartzian
2000 Apr 20
1
stack operations on vectors
It would be nie to have some basic stack operations for simple vectors and
lists. ie:
> a <- c(1,2,3,4,5)
> b <- pop(a)
> a
[1] 1 2 3 4
>b
[1] 5
> push(b, 6)
> b
[1] 5 6
notice how pop and push modify the original vector and not local copy
inside the functions environment. Is there any way to do this? I tried
this:
push <- function(vec,val) {
vec <<-