reorganized build-ins and implement a circular queue as an example

This commit is contained in:
cozis
2022-08-18 19:01:26 +02:00
parent b5b3a3e315
commit 782985e8b7
36 changed files with 486 additions and 259 deletions
+7
View File
@@ -142,6 +142,13 @@ ls[0 + 2]; # OK!
ls[true or false]; # Runtime error!!
```
To append a value to a list, increasing it's size, you can just insert the new value at the first unused position (which will have index equal to the current list size). As we'll see in the built-in chapter, to get the size of a list one can use the `count` function. Which means appending to a list can be done like this:
```py
ls = [1, 2, 3];
ls[count(ls)] = 4;
# Now ls is [1, 2, 3, 4]
```
## Maps
Maps are defined as a list of key-value pairs:
```py