Skip to content

Commit b65b920

Browse files
committed
add
1 parent 4ecbe29 commit b65b920

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

src/functions.jl

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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+
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+
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+
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+
typeof(it)
67+
end
68+
export type_of

0 commit comments

Comments
 (0)