1 | pull(a, n, k)
|
a |
|
n |
|
k |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (a, n, k)
{
b = 0
b = a
l = 1
lr = n
while (l < lr) {
ax = b[k]
jnc = l
j = lr
while (jnc <= j) {
while (b[jnc] < ax) {
jnc = jnc + 1
}
while (b[j] > ax) {
j = j - 1
}
if (jnc <= j) {
buffer = b[jnc]
b[jnc] = b[j]
b[j] = buffer
jnc = jnc + 1
j = j - 1
}
}
if (j < k) {
l = jnc
}
if (k < jnc) {
lr = j
}
}
outp = b[k]
outp
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.