4.12 Function

The following highlights the 9 types of functions in relation to numeric strings (4.12), trigonometric function (), character strings (4.14), regular expression (4.15), date / time (4.16), logical (4.17), row/column information (4.18), Null value (4.19), data type conversion (4.20).

Table 4.12: Summary of numerical functions

Section

Function name

Function

Output type

4.96

sum($num_1,num_2,\cdots $)

Sum

$num$

4.22

avg($num_1,num_2,\cdots $)

Average

$num$

4.95

sqsum($num_1,num_2,\cdots $)

Sum of squares

$num$

4.66

min($num_1,num_2,\cdots $)

Minimum value

$num$

4.64

max($num_1,num_2,\cdots $)

Maximum value

$num$

4.76

product($num_1,num_2,\cdots $)

Product

$num$

4.39

factorial($num$)

Factorial

$num$

4.45

gcd($num_1$,$num_2$)

Greatest common divisor

$num$

4.54

lcm($num_1$,$num_2$)

Least common multiple

$num$

4.94

sqrt($num$)

Square root

$num$

4.14

abs($num$)

Absolute value

$num$

4.91

sign($num$)

Sign

$num$

4.50

int($num$)

Integer part

$num$

4.44

fract($num$)

Fraction part

$num$

4.89

round($num$,nominal value)

Rounding up

$num$

4.42

floor($num$,nominal value)

Rounding down

$num$

4.26

ceil($num$,nominal value)

Ceiling

$num$

4.75

power($num$,exponent)

Power

$num$

4.38

exp($num$)

Exponential function

$num$

4.60

log($num$,base)

logarithm

$num$

4.59

ln($num$)

Natural logarithm

$num$

4.62

log2($num$)

Binary logarithm

$num$

4.61

log10($num$)

Common logarithm

$num$

4.34

dist(type,$num_1,num_2,\cdots $)

Distance

$num$

4.35

distgps(latitude1,longtitude1,latitude2,longtitude2)

GPS distance

$num$

4.47

heron($num_1,num_2,\cdots $)

Heron’s formula

$num$

4.78

rand([random seed])

Uniform random number

$num$

4.79

randi(minimum value, maximum value[, random seed])

Uniform random number

$num$

4.72

nrand(minimum value, maximum value[, random seed])

Normal random number

$num$

4.74

pi()

Pi

$num$

4.37

e()

Napier’s constant

$num$

3.1

format()

Format output

$str$

Table 4.13: List of trigonometric functions

Section

Function Name

Function

Output range

4.15

acos($num$)

Inverse cosine

$0\sim \pi $

4.19

asin($num$)

Inverse sine

$-\pi \sim \pi $

4.20

atan($num$)

Inverse tangent

$-\pi \sim \pi $

4.21

atan2($num_1$,$num_2$)

Angle of coordinates ($num_1,num_2$)

$-\pi \sim \pi $

4.27

cos($r$)

Cosine

$-1.0\sim 1.0$

4.92

sin($r$)

Sine

$-1.0\sim 1.0$

4.97

tan($r$)

Tangent

$-\infty \sim \infty $

4.32

degree($r$)

Degree

$-\pi \sim \pi $

4.77

radian(angle)

Enter angle as input, return radian as output

$-\pi \sim \pi $

4.28

cosh($r$)

Hyperbolic cosine

$0\sim \infty $

4.93

sinh($r$)

Hyperbolic sine

$-\infty \sim \infty $

4.98

tanh($r$)

Hyperbolic tangent

$-1.0\sim 1.0$


Radian is represented by the variable $r$.
Table 4.14: Character string related functions

Section

Function name

Function

Output format

4.25

cat($token, str_1, str_2, \cdots $)

Merge character string

$str$

4.57

length($str$)

Length of character string

$num$

4.40

fixlen($str$,length,position,padding character)

Fixed length conversion

$str$

4.88

right($str$,length)

Extract substring from the end

$str$

4.56

left($str$,length)

Extract substring from the beginning

$str$

4.65

mid($str$,starting position,length)

Extract substring

$str$

4.103

toupper($str$)

Convert characters from lowercase to uppercase

$str$

4.101

tolower($str$)

Converts characters from uppercase to lowercase

$str$

4.24

capitalize($str$)

Capitalize the first character

$str$

4.51

match(search string,$str_1,str_2,\cdots $)

Search for matched strings

$bool$

4.46

hasspace($str$)

Search for white-space characters

$bool$

Table 4.15: Regular expression related functions

Section

Function name

Function

Output format

4.81

regexm($str$,regular expression)

Match whole string

$bool$

4.85

regexs($str$,regular expression)

Match

$bool$

4.84

regexrep($str$,regular expression,replacement string)

Replace matching character string

$str$

4.80

regexlen($str$,regular expression)

Match number of characters

$num$

4.83

regexpos($str$,regular expression)

Start position of character

$num$

4.87

regexstr($str$,regular expression)

Match character string

$str$

4.82

regexpfx($str$,regular expression)

Match prefix of character string

$str$

4.86

regexsfx($str$,regular expression)

Match suffix of character string

$str$

Table 4.16: Date and Time Related Functions

Section

Function Name

Function

Output

4.100

today()

Today’s date

$date$

4.70

now()

Current time

$time$

4.104

tseconds($time$)

Seconds elapsed

$num$

4.55

leapyear($dt$)

Decide leap year

$bool$

4.107

year($dt$)

Gregorian calendar

$num$

4.68

month($dt$)

Month

$num$

4.30

day($dt$)

Day

$num$

4.106

week($dt$)

Week number

$num$

4.36

dow($dt$)

Day of week

$num$

4.99

time($time$)

Hour minute second

$str$

4.31

date($time$)

Year month day

$str$

4.48

hour($time$)

Hour

$num$

4.67

minute($time$)

Minute

$num$

4.90

second($time$)

Second

$num$

4.16

age($dt_1,dt_2$)

Age

$num$

4.33

diff($dt_1,dt_2$)

Period

$num$

4.105

uxt($dt$)

Convert to UNIX time

$num$(UNIX time)

4.53

julian($dt$)

Convert to Julian day

$num$(Julian day)


$dt$ represents either $date$ or $time$.
Table 4.17: Logical Functions

Section

Function Name

Function

Output

4.17

and($bool_1,bool_2,\cdots )$

Conjunction

$bool$

4.73

or($bool_1,bool_2,\cdots )$

Disjunction

$bool$

4.69

not($bool)$

NOT

$bool$

4.49

if($bool,num_1,num_2$)

Check logical condition

$num$

4.49

if($bool,str_1,str_2$)

 

$str$

4.49

if($bool,date_1,date_2)$

 

$date$

4.49

if($bool,time_1,time_2)$

 

$time$

Table 4.18: Row/column related functions

Section

Function Name

Function

Output Format

4.58

line()

Return the processing line number

$num$

4.102

top()

Top row

$bool$

4.23

bottom()

Last row

$bool$

4.41

fldsize()

Number of fields

$num$

4.18

argsize($str_1,str_2,\cdots $)

Number of arguments

$num$

Table 4.19: NULL value related functions

Section

Function Name

Function

Output Format

4.71

nulln()

NULL value

$num$

4.71

nulls()

 

$str$

4.71

nulld()

 

$date$

4.71

nullt()

 

$time$

4.71

nullb()

 

$bool$

4.52

isnull($num$)

NULL value check

$bool$

4.52

isnull($str$)

 

$bool$

4.52

isnull($date$)

 

$bool$

4.52

isnull($time$)

 

$bool$

4.52

isnull($bool$)

 

$bool$

4.29

countnull($num_1,num_2,\cdots $)

Number of NULL values

$num$

4.29

countnull($str_1,str_2,\cdots $)

 

$num$

4.29

countnull($date_1,date_2,\cdots $)

 

$num$

4.29

countnull($time_1,time_2,\cdots $)

 

$num$

4.29

countnull($bool_1,bool_2,\cdots $)

 

$num$

Table 4.20: Type conversion related functions

4.108

$num$

$str$

$date$

$time$

$bool$

$num$

 

n2s($num$)

   

n2b($num$)

$str$

s2n($str$)

 

s2d($str$)

s2t($str$)

s2b($str$)

$date$

 

d2s($date$)

 

d2t($date$)

 

$time$

 

t2s($time$)

t2d($time$)

   

$bool$

b2n($bool$)

b2s($bool$)

     

Each cell corresponds to the conversion function from the labels in the top row to labels in the left column.
Empty cells means that conversion function is not available.