sep | R Documentation |
Spliot one object (queue/stack/deque) into two of the same type. NOTE: this function operates via side-effects AND has a return.
sep(x, k)
x |
A deque. |
k |
Index to split the deque at. |
Operates via side-effects ALTHOUGH THERE IS A NON-NULL RETURN; see examples for clarification on usage.
The split occurs after index k. So if the input x has, say,
elements 1 to n, then after running sep(x, k)
, x will
have elements 1 to k, and the return will have values
k+1, k+2, ..., n.
A deque, stack, or queue (depending on the input)
## Not run: library(dequer) s <- stack() for (i in 1:5) push(s, i) ### Split s into 2 stacks holding: (s) the first 3, and (s_last_2) last 2 elements s_last_2 <- sep(s, 3) str(s) str(s_last_5) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.