Next: , Previous: , Up: Top  


10 Named Functions

This chapter covers the non-symbol named functions. This includes some math (eg. sqrt but not +), wrapper (eg. count for #) and range (eg. within) functions.

math:    sqrt exp log sin cos div mod bar
wrapper: count first last min max sum avg      
range:   in bin within

10.1 Math Functions ⇒ sqrt exp log sin cos div mod bar

10.1.1 sqrt ⇒ sqrt x

 sqrt 2
1.414214

10.1.2 exp ⇒ exp x

 exp 1
2.718282

10.1.3 log ⇒ log x

Log computes the natural log.

 log 10
2.302585

10.1.4 sin ⇒ sin x

sin computes the sine of x where x is in radians.

 sin 0
0f
 sin 3.1416%2
1.

10.1.5 cos ⇒ cos x

cos computes the cosine of x where x is in radians.

 cos 0
1f
 cos 3.1416%4
0.7071055

10.1.6 div ⇒ x div y

y divided by x using integer division. x and y must be integers.

 2 div 7
3
 5 div 22
4

10.1.7 mod ⇒ x mod y

The remainder after y divided by x using integer division. x and y must be integers.

 12 mod 27
3
 5 mod 22
2

10.1.8 bar ⇒ x bar y

For each value in y determine the number of integer multiples of x that is less than or equal to each x.

 10 bar 9 10 11 19 20 21
0 10 10 10 20 20

10.2 Wrapper Functions ⇒ count first last min max sum avg

These functions exist as verbs but also can be called with the names above.

 n:3.2 1.7 5.6
 sum n
10.5
 +/n
10.5

10.3 Range Functions ⇒ in bin within

10.3.1 in ⇒ x in y

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

10.3.2 bin ⇒ x bin y

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
 1.025 bin n
2

10.3.3 within ⇒ x within y

Test if x is equal to or greater than y[0] and less than y[1].

 3 within (0;12)
1b
 12 within (0;12)
0b
 23 within (0;12)
0b

Next: , Previous: , Up: Top