libs/table.lua

Tue, 23 May 2023 19:46:52 +0200

author
Kim Alvefur <zash@zash.se>
date
Tue, 23 May 2023 19:46:52 +0200
changeset 489
39ed19f12dca
parent 483
33d566513eb0
permissions
-rw-r--r--

libs.encodings: Remove unused function

Unused since b496f0262a3f

483
33d566513eb0 libs/table: Add table.move
Matthew Wild <mwild1@gmail.com>
parents: 439
diff changeset
1 return {
33d566513eb0 libs/table: Add table.move
Matthew Wild <mwild1@gmail.com>
parents: 439
diff changeset
2 pack = function(...) return {n = select("#", ...); ...} end;
33d566513eb0 libs/table: Add table.move
Matthew Wild <mwild1@gmail.com>
parents: 439
diff changeset
3 create = function() return {} end;
33d566513eb0 libs/table: Add table.move
Matthew Wild <mwild1@gmail.com>
parents: 439
diff changeset
4 move = function (a1, f, e, t, a2)
33d566513eb0 libs/table: Add table.move
Matthew Wild <mwild1@gmail.com>
parents: 439
diff changeset
5 a2 = a2 or a1;
33d566513eb0 libs/table: Add table.move
Matthew Wild <mwild1@gmail.com>
parents: 439
diff changeset
6 if e >= f then
33d566513eb0 libs/table: Add table.move
Matthew Wild <mwild1@gmail.com>
parents: 439
diff changeset
7 local n = (e - f) + 1;
33d566513eb0 libs/table: Add table.move
Matthew Wild <mwild1@gmail.com>
parents: 439
diff changeset
8 if t > e or t <= f or a1 ~= a2 then
33d566513eb0 libs/table: Add table.move
Matthew Wild <mwild1@gmail.com>
parents: 439
diff changeset
9 for i = 0, n-1 do
33d566513eb0 libs/table: Add table.move
Matthew Wild <mwild1@gmail.com>
parents: 439
diff changeset
10 a2[t+i] = a1[f+i];
33d566513eb0 libs/table: Add table.move
Matthew Wild <mwild1@gmail.com>
parents: 439
diff changeset
11 end
33d566513eb0 libs/table: Add table.move
Matthew Wild <mwild1@gmail.com>
parents: 439
diff changeset
12 else
33d566513eb0 libs/table: Add table.move
Matthew Wild <mwild1@gmail.com>
parents: 439
diff changeset
13 for i = n-1, 0, -1 do
33d566513eb0 libs/table: Add table.move
Matthew Wild <mwild1@gmail.com>
parents: 439
diff changeset
14 a2[t+i] = a1[f+i];
33d566513eb0 libs/table: Add table.move
Matthew Wild <mwild1@gmail.com>
parents: 439
diff changeset
15 end
33d566513eb0 libs/table: Add table.move
Matthew Wild <mwild1@gmail.com>
parents: 439
diff changeset
16 end
33d566513eb0 libs/table: Add table.move
Matthew Wild <mwild1@gmail.com>
parents: 439
diff changeset
17 end
33d566513eb0 libs/table: Add table.move
Matthew Wild <mwild1@gmail.com>
parents: 439
diff changeset
18 return a2;
33d566513eb0 libs/table: Add table.move
Matthew Wild <mwild1@gmail.com>
parents: 439
diff changeset
19 end;
33d566513eb0 libs/table: Add table.move
Matthew Wild <mwild1@gmail.com>
parents: 439
diff changeset
20 }

mercurial