queryverse / QuerySQLite.jl
1
"""
2
    char(numbers...)
3

4
Convert a list of numbers to a string with the corresponding characters
5

6
```jldoctest
7
julia> using QuerySQLite
8

9
julia> char(65, 90)
10
"AZ"
11
```
12
"""
13 1
char(numbers...) = string(map(Char, numbers)...)
14
export char
15

16
"""
17
    if_else(switch, yes, no)
18

19
`ifelse` that you can add methods to.
20

21
```jldoctest
22
julia> using QuerySQLite
23

24
julia> if_else(true, 1, 0)
25
1
26

27
julia> if_else(false, 1, 0)
28
0
29
```
30
"""
31
function if_else(switch, yes, no)
32 1
    ifelse(switch, yes, no)
33
end
34
export if_else
35

36
"""
37
    instr(haystack, needle)
38

39
Find the first index of `needle` in `haystack`.
40

41
```jldoctest
42
julia> using QuerySQLite
43

44
julia> instr("QuerySQLite", "SQL")
45
6
46
```
47
"""
48
function instr(haystack, needle)
49 1
    first(findfirst(needle, haystack))
50
end
51
export instr
52

53
"""
54
    type_of(it)
55

56
`typeof` that you can add methods to.
57

58
```jldoctest
59
julia> using QuerySQLite
60

61
julia> type_of('a')
62
Char
63
```
64
"""
65
function type_of(it)
66 1
    typeof(it)
67
end
68
export type_of
69

70
"""
71
    hex(it)
72

73
Uppercase hexadecimal representation
74

75
```jldoctest
76
julia> using QuerySQLite
77

78
julia> hex("hello")
79
"68656C6C6F"
80
```
81
"""
82
function hex(it::Number)
83 0
    uppercase(string(it, base=16))
84
end
85
function hex(it::AbstractString)
86 1
    join(hex(byte) for byte in codeunits(it))
87
end
88
export hex

Read our documentation on viewing source code .

Loading