Skip to content

Commit 49da590

Browse files
committed
Doc Updates
-update type documentation with operations
1 parent 1eaa4a4 commit 49da590

File tree

5 files changed

+190
-189
lines changed

5 files changed

+190
-189
lines changed

docs/types/builtin.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ Unique type representing a built-in function included with the language.
88

99
Built-in functions are implemented in GLang's Rust backend, meaning they are generally faster and more stable. GLang also includes a set of pre-made functions listed [here](/docs/types/function). There are 12 built-in functions total.
1010

11+
# Operations
12+
13+
## `isbuiltin(value)`
14+
Returns `true` if `value` is a built-in function.
15+
16+
```
17+
bark(isfunction(bark)); # true!
18+
```
19+
20+
# List of Built-Ins
21+
1122
## `bark(x)`
1223
Display a value in the terminal.
1324

docs/types/function.md

Lines changed: 1 addition & 189 deletions
Original file line numberDiff line numberDiff line change
@@ -14,199 +14,11 @@ func example() {
1414
example(); # call the function
1515
```
1616

17-
GLang includes a set of pre-made functions, different from [built-in functions](/docs/types/builtin), as the pre-made functions are written in GLang itself.
18-
19-
## `isnumber(value)`
20-
Returns `true` if `value` is a number.
21-
22-
```
23-
obj x = 10;
24-
25-
bark(isnumber(x)); # true!
26-
```
27-
28-
## `isdecimal(num)`
29-
Returns `true` if `num` has a decimal place.
30-
31-
```
32-
obj x = 1.1;
33-
34-
bark(isdecimal(x)); # true!
35-
```
36-
37-
## `isstring(value)`
38-
Returns `true` if `value` is a string.
39-
40-
```
41-
obj x = "This is a string.";
42-
43-
bark(isstring(x)); # true!
44-
```
45-
46-
## `islist(value)`
47-
Returns `true` if `value` is a list.
48-
49-
```
50-
obj x = [1, 2, 3];
51-
52-
bark(islist(x)); # true!
53-
```
17+
# Operations
5418

5519
## `isfunction(value)`
5620
Returns `true` if `value` is a function.
5721

5822
```
5923
bark(isfunction(push)); # true!
6024
```
61-
62-
## `isbuiltin(value)`
63-
Returns `true` if `value` is a built-in function.
64-
65-
```
66-
bark(isfunction(bark)); # true!
67-
```
68-
69-
## `push(list, value)`
70-
Adds the `value` to `list`.
71-
72-
```
73-
obj x = [1, 2, 3];
74-
push(x, 4);
75-
76-
bark(x); # output: [1, 2, 3, 4]
77-
```
78-
79-
## `append(list_a, list_b)`
80-
Combine a list with another list by copying `list_b`'s elements into `list_a`.
81-
82-
```
83-
obj x = [1, 2, 3];
84-
obj y = [4, 5, 6];
85-
append(x, y);
86-
87-
bark(x); # output: [1, 2, 3, 4, 5, 6]
88-
```
89-
90-
## `remove(list, index)`
91-
Removes the value at `index` inside `list` (optionally returns the removed value if necessary).
92-
93-
```
94-
obj x = [1, 2, 3];
95-
remove(x, 0);
96-
97-
bark(x); # output: [2, 3]
98-
```
99-
100-
## `retrieve(list, index)`
101-
Returns the value at `index` inside `list`.
102-
103-
```
104-
obj x = [1, 2, 3];
105-
obj value_in_list = retrieve(x, 0);
106-
107-
bark(value_in_list); # output: 1
108-
```
109-
110-
## `join(string_a, string_b)`
111-
Combine two strings together and return the new copy.
112-
113-
```
114-
obj x = "Hello, ";
115-
obj y = "world!";
116-
117-
bark(join(x, y)); # output: Hello, world!
118-
```
119-
120-
## `startswith(str, chars)`
121-
Returns `true` if `str` begins with `chars`.
122-
123-
```
124-
obj x = "12345";
125-
126-
bark(startswith(x, "1")); # true!
127-
```
128-
129-
## `endswith(str, chars)`
130-
Returns `true` if `str` ends with `chars`.
131-
132-
```
133-
obj x = "12345";
134-
135-
bark(endswith(x, "5")); # true!
136-
```
137-
138-
## `charat(str, index)`
139-
Returns the character at `index` of `string`.
140-
141-
```
142-
obj x = "12345";
143-
144-
bark(charat(x, 0)); # output: 1
145-
```
146-
147-
## `clear(value)`
148-
Clears a list or string and returns a new copy.
149-
150-
### list
151-
152-
```
153-
obj x = [1, 2, 3, 4];
154-
obj x = clear(x);
155-
156-
bark(x); # output: []
157-
```
158-
159-
### string
160-
161-
```
162-
obj x = "This is a string";
163-
obj x = clear(x);
164-
165-
bark(x); # output:
166-
```
167-
168-
## `reverse(value)`
169-
Reverses a list or string.
170-
171-
- Lists are reversed **in place** (no new copy).
172-
- Strings are recreated in reverse.
173-
174-
### list
175-
176-
```
177-
obj x = [1, 2, 3, 4];
178-
reverse(x);
179-
180-
bark(x); # output: [4, 3, 2, 1]
181-
```
182-
183-
### string
184-
185-
```
186-
obj x = "This is a string";
187-
obj x = reverse(x);
188-
189-
bark(x); # output: gnirts a si sihT
190-
```
191-
192-
## `contains(value, object)`
193-
Returns `true` if `value` contains the specified `object`.
194-
195-
- On a string, `object` is treated as the set of characters or substring to search for.
196-
- On a list, `object` is treated as the element to search for.
197-
198-
### list
199-
200-
```
201-
obj x = [1, 2, 3, 4];
202-
203-
bark(contains(x, 1)); # true!
204-
```
205-
206-
### string
207-
208-
```
209-
obj x = "Hello, World!";
210-
211-
bark(contains(x, "Hello")); # true!
212-
```

docs/types/list.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,84 @@ obj x = [1, 2, 3];
1111
1212
bark(x);
1313
```
14+
15+
# Operations
16+
17+
## `islist(value)`
18+
Returns `true` if `value` is a list.
19+
20+
```
21+
obj x = [1, 2, 3];
22+
23+
bark(islist(x)); # true!
24+
```
25+
26+
## `push(list, value)`
27+
Adds the `value` to `list`.
28+
29+
```
30+
obj x = [1, 2, 3];
31+
push(x, 4);
32+
33+
bark(x); # output: [1, 2, 3, 4]
34+
```
35+
36+
## `append(list_a, list_b)`
37+
Combine a list with another list by copying `list_b`'s elements into `list_a`.
38+
39+
```
40+
obj x = [1, 2, 3];
41+
obj y = [4, 5, 6];
42+
append(x, y);
43+
44+
bark(x); # output: [1, 2, 3, 4, 5, 6]
45+
```
46+
47+
## `remove(list, index)`
48+
Removes the value at `index` inside `list` (optionally returns the removed value if necessary).
49+
50+
```
51+
obj x = [1, 2, 3];
52+
remove(x, 0);
53+
54+
bark(x); # output: [2, 3]
55+
```
56+
57+
## `retrieve(list, index)`
58+
Returns the value at `index` inside `list`.
59+
60+
```
61+
obj x = [1, 2, 3];
62+
obj value_in_list = retrieve(x, 0);
63+
64+
bark(value_in_list); # output: 1
65+
```
66+
67+
## `contains(list, object)`
68+
Returns `true` if `list` contains the specified `object`. `object` is treated as the element to search for.
69+
70+
```
71+
obj x = [1, 2, 3, 4];
72+
73+
bark(contains(x, 1)); # true!
74+
```
75+
76+
## `reverse(list)`
77+
Reverses `list` **in place** (no new copy).
78+
79+
```
80+
obj x = [1, 2, 3, 4];
81+
reverse(x);
82+
83+
bark(x); # output: [4, 3, 2, 1]
84+
```
85+
86+
## `clear(list)`
87+
Clears `list` and returns a new copy.
88+
89+
```
90+
obj x = [1, 2, 3, 4];
91+
obj x = clear(x);
92+
93+
bark(x); # output: []
94+
```

docs/types/number.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,23 @@ obj y = 10.0; # decimal
1212
```
1313

1414
Each number is stored as a 64 bit floating point, meaning the number type can be stored both as an integer or float.
15+
16+
# Operations
17+
18+
## `isnumber(value)`
19+
Returns `true` if `value` is a number.
20+
21+
```
22+
obj x = 10;
23+
24+
bark(isnumber(x)); # true!
25+
```
26+
27+
## `isdecimal(num)`
28+
Returns `true` if `num` has a decimal place.
29+
30+
```
31+
obj x = 1.1;
32+
33+
bark(isdecimal(x)); # true!
34+
```

0 commit comments

Comments
 (0)