Template
1
0
mirror of https://github.com/bol-van/zapret2.git synced 2026-03-14 06:13:09 +00:00

zapret-lib: bitable

This commit is contained in:
bol-van
2026-01-11 11:21:12 +03:00
parent 02b895910b
commit 3e69e1b8c1
3 changed files with 14 additions and 0 deletions

View File

@@ -2256,10 +2256,12 @@ function blob_or_def(desync, name, def)
```
function barray(a, packer)
function btable(a, packer)
function bitable(a, packer)
```
- `barray` uses only numeric indices starting from 1. The order is preserved.
- `btable` uses all indices but does not guarantee order.
- `bitable` uses onlt numeric indices and guarantees order.
Packs elements of array `a` in ascending order of index from 1 to the last.
`packer` is a function that takes an element of `a` and returns a raw string.

View File

@@ -2421,10 +2421,12 @@ function blob_or_def(desync, name, def)
```
function barray(a, packer)
function btable(a, packer)
function bitable(a, packer)
```
- barray использует только числовые индексы, начиная с 1. порядок соблюдается
- btable использует все индексы, но не гарантирует порядок
- bitable использует только числовые индексы от 1 и гарантирует порядок
Упаковка элементов массива a в порядке возрастания индекса от 1 до последнего.
`packer` - функция, берущая элемент a и возвращающая raw string.

View File

@@ -330,6 +330,16 @@ function btable(a, packer)
return s
end
end
-- convert table a to packed string using 'packer' function. numeric indexes only, ordered
function bitable(a, packer)
if a then
local s=""
for k,v in ipairs(a) do
s = s .. packer(v)
end
return s
end
end
-- sequence comparision functions. they work only within 2G interval
-- seq1>=seq2