游戏王残局简化版

Annotation For 残局文料/lua_lib/常用库.lua
Login

Annotation For 残局文料/lua_lib/常用库.lua

Origin for each line in 残局文料/lua_lib/常用库.lua from check-in 9942dfa51d:

9942dfa51d 2024-02-04    1: local d = {}
1fd4d78c98 2024-02-03    2: local 简文件库 = require("lfs")
b29c01f0b6 2024-02-02    3: --~ 排
2c6261c44d 2024-02-03    4: --~ 办排中值的能
fb63b2804e 2024-02-03    5: --~ 入参2
fb63b2804e 2024-02-03    6: --~ 入参3
fb63b2804e 2024-02-03    7: --~ 入参4
9942dfa51d 2024-02-04    8: function d.历排(o1_0, o1, o2_0, o3_0, o4_0)
dbb3ab98a4 2024-02-03    9:   local k1_0
fb63b2804e 2024-02-03   10:   --~ 集排
dbb3ab98a4 2024-02-03   11:   k1_0 = {}
dbb3ab98a4 2024-02-03   12:   for o2 = 1, #o1_0 do
dbb3ab98a4 2024-02-03   13:     k1_0[#k1_0 + 1] = o1(o1_0[o2], o2_0, o3_0, o4_0)
fb63b2804e 2024-02-03   14:     end
dbb3ab98a4 2024-02-03   15:   return k1_0
fb63b2804e 2024-02-03   16:   end
fb63b2804e 2024-02-03   17: --~ 文
fb63b2804e 2024-02-03   18: --~ 历文的能
fb63b2804e 2024-02-03   19: --~ 入参2
fb63b2804e 2024-02-03   20: --~ 入参3
9942dfa51d 2024-02-04   21: function d.历文(o1, o2, o1_0, o2_0)
4af7b78130 2024-02-03   22:   local k1_0
0b316b136c 2024-02-03   23:   --~ 集排
4af7b78130 2024-02-03   24:   k1_0 = {}
4af7b78130 2024-02-03   25:   for o3_0 in o2(o1, o1_0, o2_0) do
4af7b78130 2024-02-03   26:     k1_0[#k1_0 + 1] = o3_0
2fe4cafc95 2024-02-03   27:     end
4af7b78130 2024-02-03   28:   return k1_0
2fe4cafc95 2024-02-03   29:   end
2fe4cafc95 2024-02-03   30: --~ 表中值
2fe4cafc95 2024-02-03   31: --~ 值类
2fe4cafc95 2024-02-03   32: --~ 办值的能
9942dfa51d 2024-02-04   33: function d.操类(o1_0, o1, o2)
733d68b305 2024-02-04   34:   if type(o1_0) == o1 then
733d68b305 2024-02-04   35:     return o2(o1_0)
2fe4cafc95 2024-02-03   36:   else
733d68b305 2024-02-04   37:     return o1_0
1fd4d78c98 2024-02-03   38:     end
1fd4d78c98 2024-02-03   39:   end
1fd4d78c98 2024-02-03   40: --~ 排中文
1fd4d78c98 2024-02-03   41: --~ 入参2
1fd4d78c98 2024-02-03   42: --~ 入参3
1fd4d78c98 2024-02-03   43: --~ 入参4
9942dfa51d 2024-02-04   44: function d.全筛文(o1, o2, o3, o4)
d1b9d0d34f 2024-02-03   45:   if string.find(o1, o2, o3, o4) then
e94f91e6b3 2024-02-03   46:     return o1
e94f91e6b3 2024-02-03   47:     end
e94f91e6b3 2024-02-03   48:   end
e94f91e6b3 2024-02-03   49: --~ 文
e94f91e6b3 2024-02-03   50: --~ 前缀
9942dfa51d 2024-02-04   51: function d.加前缀(o1, o2)
0893c58ef4 2024-02-03   52:   return (o2 or "") .. o1
0893c58ef4 2024-02-03   53:   end
0893c58ef4 2024-02-03   54: --~ 文
0893c58ef4 2024-02-03   55: --~ 后缀
9942dfa51d 2024-02-04   56: function d.加后缀(o1, o2)
4d150d683b 2024-02-03   57:   return o1 .. (o2 or "")
4d150d683b 2024-02-03   58:   end
4d150d683b 2024-02-03   59: --~ 令
9942dfa51d 2024-02-04   60: function d.办令(o1)
4d150d683b 2024-02-03   61:   print(o1)
4d150d683b 2024-02-03   62:   os.execute(o1)
4d150d683b 2024-02-03   63:   end
4d150d683b 2024-02-03   64: --~ 文
4d150d683b 2024-02-03   65: --~ 前缀
9942dfa51d 2024-02-04   66: function d.全筛前缀(o1, o2)
4d150d683b 2024-02-03   67:   if string.sub(o1, 1, #o2) == o2 then
4d150d683b 2024-02-03   68:     return o1
4d150d683b 2024-02-03   69:     end
4d150d683b 2024-02-03   70:   end
4d150d683b 2024-02-03   71: --~ 文
4d150d683b 2024-02-03   72: --~ 后缀
9942dfa51d 2024-02-04   73: function d.全筛后缀(o1, o2)
168300f866 2024-02-03   74:   if string.sub(o1, -#o2) == o2 then
168300f866 2024-02-03   75:     return o1
168300f866 2024-02-03   76:     end
168300f866 2024-02-03   77:   end
0ebfa0e128 2024-02-04   78: --~ 目对
9942dfa51d 2024-02-04   79: function d.用令行工具操文件(o1_0)
4e48ffd0e5 2024-02-03   80:   local k1_9
4e48ffd0e5 2024-02-03   81:   --~ 令行排
9942dfa51d 2024-02-04   82:   k1_9 = d.历文(o1_0.文件目, 简文件库.dir)
9942dfa51d 2024-02-04   83:   k1_9 = d.历排(k1_9, d.全筛后缀, o1_0.文件类)
0ebfa0e128 2024-02-04   84:   for o1 = 1, #k1_9 do
9942dfa51d 2024-02-04   85:     k1_9[o1] = d.加前缀(k1_9[o1], o1_0.文件目)
9942dfa51d 2024-02-04   86:     k1_9[o1] = d.加前缀(k1_9[o1], [["]])
9942dfa51d 2024-02-04   87:     k1_9[o1] = d.加后缀(k1_9[o1], [["]])
9942dfa51d 2024-02-04   88:     k1_9[o1] = d.加前缀(k1_9[o1], o1_0.令行前缀)
9942dfa51d 2024-02-04   89:     d.办令(k1_9[o1])
4e48ffd0e5 2024-02-03   90:     end
4e48ffd0e5 2024-02-03   91:   end
4e48ffd0e5 2024-02-03   92: --~ 文件路
4e48ffd0e5 2024-02-03   93: --~ 式
9942dfa51d 2024-02-04   94: function d.读文件(o1, o2)
4e48ffd0e5 2024-02-03   95:   local k1
4e48ffd0e5 2024-02-03   96:   local k1_3
4e48ffd0e5 2024-02-03   97:   --~ 文件
4e48ffd0e5 2024-02-03   98:   k1_3 = io.open(o1, o2 or "r")
4e48ffd0e5 2024-02-03   99:   --~ 文
4e48ffd0e5 2024-02-03  100:   k1 = k1_3:read("a")
4e48ffd0e5 2024-02-03  101:   k1_3:flush()
4e48ffd0e5 2024-02-03  102:   k1_3:close()
4e48ffd0e5 2024-02-03  103:   return k1
4e48ffd0e5 2024-02-03  104:   end
4e48ffd0e5 2024-02-03  105: --~ 常量排
9942dfa51d 2024-02-04  106: function d.加对限(o1_0)
b92c73c8f3 2024-02-04  107:   for o1 = 1, #o1_0 do
9942dfa51d 2024-02-04  108:     o1_0[o1] = d.加前缀(o1_0[o1], [[k1_0["]])
b92c73c8f3 2024-02-04  109:     o1_0[o1] = string.gsub(o1_0[o1], "=", "\"]=", 1)
4e48ffd0e5 2024-02-03  110:     end
b92c73c8f3 2024-02-04  111:   table.insert(o1_0, 1, "local k1_0 = {}")
b92c73c8f3 2024-02-04  112:   table.insert(o1_0, "return k1_0")
b92c73c8f3 2024-02-04  113:   return table.concat(o1_0, "\n")
4e48ffd0e5 2024-02-03  114:   end
4e48ffd0e5 2024-02-03  115: --~ 文
4e48ffd0e5 2024-02-03  116: --~ 文件路
4e48ffd0e5 2024-02-03  117: --~ 式
9942dfa51d 2024-02-04  118: function d.写文件(o1, o2, o3)
168300f866 2024-02-03  119:   local k1_3
168300f866 2024-02-03  120:   --~ 文件
168300f866 2024-02-03  121:   k1_3 = io.open(o2, o3 or "w")
168300f866 2024-02-03  122:   k1_3:write(o1)
168300f866 2024-02-03  123:   k1_3:flush()
168300f866 2024-02-03  124:   k1_3:close()
168300f866 2024-02-03  125:   end
1b64e61bc7 2024-02-04  126: --~ 文
9942dfa51d 2024-02-04  127: function d.删左右空白(o1)
168300f866 2024-02-03  128:   o1 = string.gsub(o1, "^%s+", "")
168300f866 2024-02-03  129:   return string.gsub(o1, "%s+$", "")
168300f866 2024-02-03  130:   end
9942dfa51d 2024-02-04  131: return d