Next: Knit Functions, Previous: Expression Evaluation, Up: k9: Manual
This chapter covers the built-in named functions. This includes some math (eg. sqrt but not +), wrapper (eg. count for #) and range (eg. within) functions.
Retrieve the last element of list x.
last 5 1 2 2
Retrieve the minimum element of list x. Same as |/
.
min 5 1 2 1
Retrieve the maximum element of list x. Same as &/
.
max 5 1 2 5
Compute the sum of list x. Same as +/
.
sum 5 1 2 8
Compute the dot product of list x. Same as +/x*x
.
dot 1.2 1.3 1.4 5.09 {+/x*x} 1.2 1.3 1.4 5.09
Compute the average of list x. Same as +/x%#x
.
avg 2 4 7 10 5.75 {+/x%#x} 2 4 7 10 5.75
Compute the variance of list x.
var !10 8.25 {(+/x*x:x-avg x)%#x}@!10 8.25
TBD
TBD
TBD
TBD
Compute the exponent of x, i.e. ex.
exp 1 2.718282
Log computes the natural log.
log 10 2.302585
sin computes the sine of x where x is in radians.
sin 0 0f sin 3.1416%2 1.
cos computes the cosine of x where x is in radians.
cos 0 1f cos 3.1416%4 0.7071055
Compute the square of x.
sqr 2 4.0
Write out all permutations of integers up x-1. Display them as columns.
prm 3 0 1 1 0 2 2 1 0 2 2 0 1 2 2 0 1 1 0
Compute the running sum of list x. Sames as +\
.
sums !10 0 1 3 6 10 15 21 28 36 45
Compute the difference between each element in list x and the previous value. If delta is called with two parameters then x will be used as the first value to delta instead of the default 0.
deltas 1 5 10 1 4 5 1 deltas 1 5 10 0 4 5
Determine whether vector x has element y. Simliar to in but with the arguments reversed.
`a`b`c`a`b has `a 1b `a`b`c`a`b has `d 0b `a`b`c`a`b has `a`b`x`y`z 11000b (1 2;4 5 6;7 9)has(1 2;8 9) 10b
Given a sorted (increasing) list x, find the greatest index, i, where y>x[i].
n:exp 0.01*!5;n 1 1.01005 1.020201 1.030455 1.040811 n bin 1.025 3
Determine if x is in list y. Similar to has but arguments reversed.
`b in `a`b`d`e 1b `c in `a`b`d`e 0b
Test if x is equal to or greater than y[0] and less than y[1].
3 within 0 12 1b 0 within 0 12 1b 12 within 0 12 0b 23 within 0 12 0b
For each value in y determine the maximum multiple of x that is less than or equal to each y.
10 bar 9 10 11 19 20 21 0 10 10 10 20 20
Compute the length x moving sum of list y.
3 msum !10 0 1 3 6 9 12 15 18 21 24
Compute the length x moving average of list y.
3 mavg !10 0 0.3333333 1 2 3 4 5 6 7 8
Next: Knit Functions, Previous: Expression Evaluation, Up: k9: Manual