Skip to content

Commit af9cdcd

Browse files
committed
Update readme.md
1 parent 5abc72b commit af9cdcd

File tree

1 file changed

+134
-4
lines changed

1 file changed

+134
-4
lines changed

readme.md

Lines changed: 134 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
# ZeroLang(still woking on it!)
23

34
## 0. Introduction
@@ -147,6 +148,139 @@ add(2, 3) # Returns 5
147148

148149
---
149150

151+
## ⚙️ Built-in Functions
152+
153+
ZeroLang provides several built-in functions for common operations:
154+
155+
### `print(value)`
156+
157+
Prints the value to the console.
158+
159+
```plaintext
160+
print("Hello, World!")
161+
```
162+
163+
---
164+
165+
### `print_ret(value)`
166+
167+
Returns the string representation of the value (does not print).
168+
169+
```plaintext
170+
var msg = print_ret(123)
171+
```
172+
173+
---
174+
175+
### `input()`
176+
177+
Prompts user for input as a string.
178+
179+
```plaintext
180+
var name = input()
181+
```
182+
183+
---
184+
185+
### `input_int()`
186+
187+
Prompts user for input until a valid integer is entered.
188+
189+
```plaintext
190+
var age = input_int()
191+
```
192+
193+
---
194+
195+
### `clear()` / `cls()`
196+
197+
Clears the terminal screen (cross-platform).
198+
199+
```plaintext
200+
clear()
201+
cls()
202+
```
203+
204+
---
205+
206+
### `is_num(value)`
207+
208+
Returns `True` if value is a number, otherwise `False`.
209+
210+
```plaintext
211+
is_num(10) # True
212+
is_num("abc") # False
213+
```
214+
215+
---
216+
217+
### `is_str(value)`
218+
219+
Returns `True` if value is a string.
220+
221+
```plaintext
222+
is_str("hello") # True
223+
```
224+
225+
---
226+
227+
### `is_list(value)`
228+
229+
Returns `True` if value is a list.
230+
231+
```plaintext
232+
is_list([1, 2, 3]) # True
233+
```
234+
235+
---
236+
237+
### `is_fun(value)`
238+
239+
Returns `True` if value is a function.
240+
241+
```plaintext
242+
var f = func(x) -> x + 1
243+
is_fun(f) # True
244+
```
245+
246+
---
247+
248+
### `append(list, value)`
249+
250+
Appends a value to the end of the list.
251+
252+
```plaintext
253+
var l = [1, 2]
254+
append(l, 3)
255+
# l is now [1, 2, 3]
256+
```
257+
258+
---
259+
260+
### `pop(list, index)`
261+
262+
Removes and returns the element at the given index.
263+
264+
```plaintext
265+
var l = [5, 6, 7]
266+
pop(l, 1) # returns 6, l becomes [5, 7]
267+
```
268+
269+
---
270+
271+
### `extend(listA, listB)`
272+
273+
Extends `listA` by appending all elements from `listB`.
274+
275+
```plaintext
276+
var a = [1]
277+
var b = [2, 3]
278+
extend(a, b)
279+
# a becomes [1, 2, 3]
280+
```
281+
282+
---
283+
150284
## 🔍 Example Program
151285

152286
```plaintext
@@ -161,7 +295,3 @@ square(4)
161295
Lexical and syntax errors are handled by classes like `IllegalCharError`, `InvalidSyntaxError`, and `RTError`. They provide clear messages with line numbers and context arrows.
162296

163297
---
164-
165-
166-
167-

0 commit comments

Comments
 (0)