# Primitive Functions¶

Note

The examples of primitives come from the ELI Primer which is available at ELI Document

## Symbol Table¶

Name Symbol Name Symbol
jot .
dot :
each
unique/equal =
minus(negate/substract) -
at(pi/circle) @ del @.
epsilon(member) ? random ?.
star(signum/multiply) * natural log/power *.
percent(reciprocal/div) % log %.
bar(absolute/residue) | gamma(factorial/binom) |.
rho(shape/reshape) # domino #.
turn(reverse/rotate) \$ reverse/roate(1st axis) \$.
iota(interval/index_of) ! execute/drop !.
count/and ^ first/take ^.
or & flip(transpose) &.
high_minus _ lower(floor/minimum) _.
not ~ upper(ceiling/maximum) ~.
slash(reduce/compress) / slashdot(reduct1/compre1) /.
back slash(scan/expand) \ back slash(scan1/expand1) \.
catenate , raze/catenate(1st axis) ,.
assign <-
branch ->
nand ~^
nor ~&
not equal ~=
less or equal <=
greater or equal >=
comment //

A monadic function only takes one argument. For example, `f x` where `f` is the monadic function and `x` is the only argument the function takes. Usually, the function `f` has different behaviors based on different types of input data.

### Unique (=)¶

• Domain of the parameter `x`

 Boolean ✓ Month ✓ List ✗ Integer ✓ Date ✓ Enumeration ✗ Float ✓ Datetime ✓ Dictionary ✗ Char ✓ Minute ✓ Keyed table ✗ Complex ✓ Second ✓ Table ✗ Symbol ✓ Time ✓
• Code examples

```      V
86 25 55 48 78 95 36 36 14 65
=V
86 25 55 48 78 95 36 14 65
V=36
0 0 0 0 0 0 1 1 0 0
```

### Negate (-)¶

• Domain of the parameter `x`

 Boolean ✓ Month ✗ List ✗ Integer ✓ Date ✗ Enumeration ✗ Float ✓ Datetime ✗ Dictionary ✗ Char ✓ Minute ✗ Keyed table ✗ Complex ✓ Second ✗ Table ✗ Symbol ✗ Time ✗
• Code examples

```      V
86 25 55 48 78 95 36 36 14 65
-V
_86 _25 _55 _48 _78 _95 _36 _36 _14 _65
```

### Pi (@)¶

• Domain of the parameter `x` (The same as negate)

• Code examples

```      @0 1 2 3
0 3.141592654 6.283185307 9.424777961
```

### Signum (*)¶

• Domain of the parameter `x` (The same as negate)

• Code examples

```    V
86 25 55 48 78 95 36 36 14 65
P
17.3 22.3 24.3 17.5 21.4 18.4 17.2 15 20.8 21.8
*P-P0<-20
_1 1 1 _1 1 _1 _1 _1 1 1
V**P-P0
_86 25 55 _48 78 _95 _36 _36 14 65
```

### Reciprocal (%)¶

• Domain of the parameter `x` (The same as negate)

• Code examples

```      %0
Error: domain error
%0
^
%1 2 4 8
1 0.5 0.25 0.125
```

### Absolute (|)¶

• Domain of the parameter `x` (The same as negate)

• Code examples

```      | _1 2 _3.2 5 0 _10
1 2 3.2 5 0 10
```

### Shape (#)¶

• Domain of the parameter `x`

 Boolean ✓ Month ✓ List ✓ Integer ✓ Date ✓ Enumeration ✓ Float ✓ Datetime ✓ Dictionary ✓ Char ✓ Minute ✓ Keyed table ✓ Complex ✓ Second ✓ Table ✓ Symbol ✓ Time ✓
• Code examples

```      a<-2 3#9 2 3 4 5 6
a
9 2 3
4 5 6
#a
2 3
#empv<-0#a
0
#empm<-0 10#'A'
0 10
```

### Reverse (\$)¶

• Domain of the parameter `x`

 Boolean ✓ Month ✓ List ✓ Integer ✓ Date ✓ Enumeration ✓ Float ✓ Datetime ✓ Dictionary ✗ Char ✓ Minute ✓ Keyed table ✗ Complex ✓ Second ✓ Table ✗ Symbol ✓ Time ✓
• Code examples

```      V
86 25 55 48 78 95 36 36 14 65
\$V
65 14 36 36 95 78 48 55 25 86
```

• Domain of the parameter `x`

 Boolean ✓ Month ✓ List ✗ Integer ✓ Date ✓ Enumeration ✗ Float ✓ Datetime ✓ Dictionary ✗ Char ✓ Minute ✓ Keyed table ✗ Complex ✓ Second ✓ Table ✗ Symbol ✓ Time ✓
• Code examples

```      V
86 25 55 48 78 95 36 36 14 65
<V
9 2 7 8 4 3 10 5 1 6
V[<V]
14 25 36 36 48 55 65 78 86 95
```

• Domain of the parameter `x` (The same as grade up)

• Code examples

```      V
86 25 55 48 78 95 36 36 14 65
>V
6 1 5 10 3 4 7 8 2 9
V[>V]
95 86 78 65 55 48 36 36 25 14
```

### Interval (!)¶

• Domain of the parameter `x` (The same as not)

• Code examples

```    !5
1 2 3 4 5
!2.3
Error: domain error
!2.3
^
```

The generated interval is influenced by the system variable []IO.

```      []IO<-0
0
!12
0 1 2 3 4 5 6 7 8 9 10 11
```

### Count (^)¶

• Domain of the parameter `x` (The same as shape)

• Code examples

```    ^`abc
1
s3<-`abc `ddl `comp
^s3
4
```

### Conjugate (+)¶

• Domain of the parameter `x` (The same as negate)

• Code examples

```      +_1 2 _3.2 5 0 _10
_1 2 _3.2 5 0 _10
+1j2 2.3j_3
1j_2 2.3j3
```

### High_minus (_)¶

• Domain of the parameter `x` (The same as negate)

• Code examples

```      _1 2 3
_1 2 3
```

### Not (~)¶

• Domain of the parameter `x`

 Boolean ✓ Month ✗ List ✗ Integer ✓ Date ✗ Enumeration ✗ Float ✗ Datetime ✗ Dictionary ✗ Char ✗ Minute ✗ Keyed table ✗ Complex ✗ Second ✗ Table ✗ Symbol ✗ Time ✗
• Code examples

```      ~0 1 1 0
1 0 0 1
```

### Natural logarithm (*.)¶

• Domain of the parameter `x` (The same as negate)

• Code examples

```      e<-*.1
e
2.7182818
*. _1 0 1 2 3
0.36787944 1 2.7182818 7.3890561 20.085537
e*. _1 0 1 2 3
0.36787944 1 2.7182818 7.3890561 20.085537
```

### Factorial (|.)¶

• Domain of the parameter `x` (The same as negate)

• Code examples

```      |.1 2 3 4 5
1 2 6 24 120
```
• Note: non-negative integer is required.

### Floor (_.)¶

• Domain of the parameter `x` (The same as negate)

• Code examples

```      _. 0.5 _1.2 0 3 _5
0 _2 0 3 _5
```
• Note: similar to the function `floor` in C

### Ceiling (~.)¶

• Domain of the parameter `x` (The same as negate)

• Code examples

```      ~. 0.5 _1.2 0 3 _5
1 _1 0 3 _5
```
• Note: similar to the function `ceil` in C

### Raze (,.)¶

• Domain of the parameter `x`

 Boolean ✓ Month ✓ List ✓ Integer ✓ Date ✓ Enumeration ✗ Float ✓ Datetime ✓ Dictionary ✗ Char ✓ Minute ✓ Keyed table ✗ Complex ✓ Second ✓ Table ✗ Symbol ✓ Time ✓
• Code examples

```      ,(1 2;3 4)
<1 2
<3 4
,.(1 2;3 4)
1 2 3 4
```
• Note: currently designed for flattening lists

A dyadic function only takes two arguments. For example, `y f x` where `f` is the monadic function and `x` and `y` are the two arguments the function takes. Usually, the function `f` has different behaviors based on different kinds of input data.

### Multiply (*)¶

```      2j5 * 3j2.5
_6.5j20
```

### Divide (%)¶

```      (!6)%2
0.5 1 1.5 2 2.5 3
24%!6
24 12 8 6 4.8 4
```

```      %!6
1 0.5 0.33333333 0.25 0.2 0.16666667
```

Now to take the cubic root of numbers or various roots of a number, we do

```      1 2 8 1000 81 125 *.%3
1 1.259921 2 10 4.3267487 5
1024*.%1 2 3 5 10
1024 32 10.079368 4 2
```

### Residue (|)¶

```      2|!12
1 0 1 0 1 0 1 0 1 0 1 0
2 3 4.5|9
1 0 0
3.2|3 6.4 7
3 0 0.6
```

### Reshape (#)¶

```      a<-2 3#9 2 3 4 5 6
a
9 2 3
4 5 6
#a
2 3
```

### Index Of (!)¶

```    5 1 7 9 3 7 ! 5
1
5 1 7 9 3 7 ! 7
3
```

### And (^)¶

```      1 1 0 1 0 0 ^ 0 1 0 0 1 0
0 1 0 0 0 0
```

### Or (&)¶

```      1 1 0 1 0 0 & 0 1 0 0 1 0
1 1 0 1 1 0
```

```      1+A<-10
11
n+1
Error: value error
n+1
^
2j5+3j2.5
5j7.5
```

### Power (*.)¶

```      2 _3 10 0.5 25 *. 2
4 9 100 0.25 625
10 *. _1 0 1 2 3
0.1 1 10 100 1000
2*.!10
2 4 8 16 32 64 128 256 512 1024
4 9 100 0.25 625 *.0.5
2 3 10 0.5 25
_1 *. 0.5
0j1
```

### Catenate (,)¶

```      0,!10
0 1 2 3 4 5 6 7 8 9 10
(!10),_1
1 2 3 4 5 6 7 8 9 10 _1
'WATCH OUT','!'
WATCH OUT!
'WATCH OUT',' GUYS!'
WATCH OUT GUYS!
100 200,2 3 5
100 200 2 3 5
```

## Mixed¶

### Each (”)¶

```      *"(_2 3;4 _5 6)
<_1 1
<1 _1 1
*"_2 3
_1 1
```
• Apply a monadic operator to a list or a simple array

### Log (%.)¶

```      10%. 1 10 100 1000 10000
0 1 2 2 3 4
10%. 1 10 100 1000 10000 100000
0 1 2 3 4 5
2%. 0.5 1 2 4 8 16
_1 0 1 2 3 4
2 3 10%. 4 9 100
2 2 2
e<-*.1
e
2.718282
%.1 10 100 1000 10000 100000
0 2.302585 4.60517 6.907755 9.21034 11.512925
e%.1 10 100 1000 10000 100000
0 2.302585 4.60517 6.907755 9.21034 11.512925
```

### Assign (<-)¶

```      A<-'BC'
ch<-'abcde''1234'
ch
abcde'1234
A
BC
```