Description Usage Arguments Details Value References See Also Examples
View source: R/insert_top.rstack.R
Insert an element onto the top of an rstack.
1 2 | ## S3 method for class 'rstack'
insert_top(s, e, ...)
|
s |
rstack to insert onto. |
e |
element to insert. |
... |
additional arguments to be passed to or from methods (ignored). |
Runs in O(1) time worst-case. Does not semantically modify the original structure (i.e, this function is "pure").
modified version of the stack with new element at top.
Okasaki, Chris. Purely Functional Data Structures. Cambridge University Press, 1999.
rstack
for information on rstacks, without_top
for removal of top elements.
1 2 3 4 5 6 7 8 | s <- rstack()
s <- insert_top(s, "a")
s <- insert_top(s, "b")
print(s)
s2 <- insert_top(s, "c")
print(s2)
print(s)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.