aboutsummaryrefslogtreecommitdiff
path: root/docs/table.md
diff options
context:
space:
mode:
authorame <[email protected]>2023-12-19 11:38:17 -0600
committerame <[email protected]>2023-12-19 11:38:17 -0600
commit64d3e78262c35857ae9310c9b9da9ee91ea43dd2 (patch)
treeb130d479b882b903da691164f82557163c7dc048 /docs/table.md
parent595fd25a80c569d104bc53cbfb9e46654134b4e1 (diff)
some docs:3
Diffstat (limited to 'docs/table.md')
-rw-r--r--docs/table.md115
1 files changed, 115 insertions, 0 deletions
diff --git a/docs/table.md b/docs/table.md
new file mode 100644
index 0000000..e58dd54
--- /dev/null
+++ b/docs/table.md
@@ -0,0 +1,115 @@
+# table (tables and sorting)
+
+## sorting
+
+|name|accepted types|type of sorting|order|
+|---|---|---|---|
+|quicksort| double,int | comparison | greatest -> least |
+|mergesort| double,int | comparison | greatest -> least |
+|shellsort| double,int | comparison | greatest -> least |
+|bubblesort| double,int | comparison | greatest -> least |
+|heapsort| double,int | comparison | greatest -> least |
+|countingsort| int | non-comparison | least -> greatest|
+|miraclesort| double,int | esoteric | ? greatest -> least |
+|stalinsort| double,int | esoteric | greatest -> least |
+|slowsort| double,int | esoteric | greatest -> least |
+|bogosort| double,int | esoteric | greatest -> least |
+
+### usage
+
+```lua
+local test = {5, 10, 922, -32, 554, 0};
+locla test_sorted = llib.array.mergesort(test); -- 922, 554, 10, 5, 0, -32
+```
+
+## utils
+
+### len
+
+'accepts any table
+
+returns length of table, including associative arrays
+
+```lua
+llib.array.len({a = 55, b = 22}); -- 2
+```
+
+### reverse
+
+'accepts any table
+
+reverses a table
+
+```lua
+llib.array.reverse({5, 4, 22}) -- 22, 4, 5
+```
+
+### least/greatest
+
+'accepts a table with numbers
+
+gets smallest/largest value of a table
+
+```lua
+llib.array.greatest({22, 99, 99.9}) -- 99.9
+```
+
+### shuffle
+
+'accepts any table
+
+randomizes array
+
+```lua
+llib.array.shuffle({5, 22, 89}) -- 22, 89, 5
+```
+### sum
+
+'accepts a table with numbers
+
+gets sum of each element in a table
+
+```lua
+llib.array.sum({5, 4, 3}) --12
+```
+
+### index
+
+'accepts any table and a value
+
+gets index of item in array linearly, returns -1 if not present
+
+```lua
+llib.array.index({5, 4, 3}, 4) -- 2
+```
+
+### sindex
+
+'accepts a sorted table with numbers and a value
+
+gets index through binary search, -1 if not present
+
+```lua
+llib.array.sindex({2, 4, 8}, 8) -- 3
+```
+
+### split
+
+'accepts a string and a delimiter
+
+splits a string by arg2, returns a array
+
+```lua
+llib.array.split("hello world"," ") -- "hello", "world"
+```
+
+### to_char_array
+
+'accepts a string
+
+returns a char array from a string
+
+```lua
+llib.array.to_char_array("meow") -- "m", "e", "o", "w"
+```
+