Description Usage Arguments Details Value See Also Examples
Returns the top n elements of an rstack as an stack, or all of the elements
if length(x) < n
.
1 2 |
x |
rstack to get the head/top of. |
n |
number of elements to get. |
... |
arguments to be passed to or from other methods (ignored). |
Runs in O(n) time (in the size of the number of elements requested).
an rstack
.
1 2 3 4 5 6 7 8 | s <- rstack()
s <- insert_top(s, "a")
s <- insert_top(s, "b")
s <- insert_top(s, "c")
st <- head(s, n = 2)
print(st)
print(s)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.