summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/luatex/penlight/penlight.pdfbin29537 -> 29642 bytes
-rw-r--r--Master/texmf-dist/doc/luatex/penlight/penlight.tex2
-rw-r--r--Master/texmf-dist/tex/luatex/penlight/penlight.sty4
-rw-r--r--Master/texmf-dist/tex/luatex/penlight/penlightextras.lua128
4 files changed, 46 insertions, 88 deletions
diff --git a/Master/texmf-dist/doc/luatex/penlight/penlight.pdf b/Master/texmf-dist/doc/luatex/penlight/penlight.pdf
index 8d07293e47d..1edb8bf2b54 100644
--- a/Master/texmf-dist/doc/luatex/penlight/penlight.pdf
+++ b/Master/texmf-dist/doc/luatex/penlight/penlight.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/luatex/penlight/penlight.tex b/Master/texmf-dist/doc/luatex/penlight/penlight.tex
index 68b8f1bb40e..79a5d085891 100644
--- a/Master/texmf-dist/doc/luatex/penlight/penlight.tex
+++ b/Master/texmf-dist/doc/luatex/penlight/penlight.tex
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje@gmail.com)
-% 2021-11-07
+% 2021-12-15
% Copyright (C) 2021 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/Master/texmf-dist/tex/luatex/penlight/penlight.sty b/Master/texmf-dist/tex/luatex/penlight/penlight.sty
index 1f1fccc042b..9f0ead874fa 100644
--- a/Master/texmf-dist/tex/luatex/penlight/penlight.sty
+++ b/Master/texmf-dist/tex/luatex/penlight/penlight.sty
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje@gmail.com)
-% 2021-11-07
+% 2021-12-15
% Copyright (C) 2021 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -22,7 +22,7 @@
% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
% OR OTHER DEALINGS IN THE SOFTWARE.
-\ProvidesPackage{penlight}[2021-11-07]
+\ProvidesPackage{penlight}[2021-12-15]
\RequirePackage{luacode}
diff --git a/Master/texmf-dist/tex/luatex/penlight/penlightextras.lua b/Master/texmf-dist/tex/luatex/penlight/penlightextras.lua
index 13d0ab5817c..3479eb3fa04 100644
--- a/Master/texmf-dist/tex/luatex/penlight/penlightextras.lua
+++ b/Master/texmf-dist/tex/luatex/penlight/penlightextras.lua
@@ -20,7 +20,6 @@ function help_wrt(s1, s2) -- helpful printing, makes it easy to debug, s1 is obj
wrt('\n^^^^^\n')
end
-
function prt_array2d(t)
for _, r in ipairs(t) do
local s = ''
@@ -83,7 +82,7 @@ end
-- -- -- -- functions below extend the array2d module
-local function map_slice1(func, L, i1, i2) -- map a function to a slice of an array, can use PlcExpr
+function pl.array2d.map_slice1(func, L, i1, i2) -- map a function to a slice of an array, can use PlcExpr
i2 = i2 or i1
local len = #L
i1 = check_index(i1, len)
@@ -95,7 +94,7 @@ local function map_slice1(func, L, i1, i2) -- map a function to a slice of an ar
return L
end
-local function map_slice2(func, M, i1, j1, i2, j2) -- map a function to a slice of a Matrix
+function pl.array2d.map_slice2(func, M, i1, j1, i2, j2) -- map a function to a slice of a Matrix
i1, j1, i2, j2 = check_slice(M, i1, j1, i2, j2)
--for i,j in array2d.iter(M, true, i1, j1, i2, j2) do --todo this did not work, penlight may have fixed this
func = check_func(func)
@@ -107,12 +106,12 @@ local function map_slice2(func, M, i1, j1, i2, j2) -- map a function to a slice
return M
end
-local function map_columns(func, M, j1, j2) -- map function to columns of matrix
+function pl.array2d.map_columns(func, M, j1, j2) -- map function to columns of matrix
j2 = j2 or j1
return map_slice2(func, M, 1, j1, -1, j2)
end
-local function map_rows(func, M, i1, i2) -- map function to rows of matrix
+function pl.array2d.map_rows(func, M, i1, i2) -- map function to rows of matrix
i2 = i2 or i1
return map_slice2(func, M, i1, 1, i2, -1)
end
@@ -120,7 +119,7 @@ end
-- -- -- -- -- -- -- --
-function sortOP(M, op, ele) -- sort a 2d array based on operator criteria, ele is column, ie sort on which element
+function pl.array2d.sortOP(M, op, ele) -- sort a 2d array based on operator criteria, ele is column, ie sort on which element
M_new = {}
for row in pl.seq.sort(M, comp_2ele_func(op, ele)) do
M_new[#M_new+1] = row
@@ -128,13 +127,13 @@ function sortOP(M, op, ele) -- sort a 2d array based on operator criteria, ele i
return M_new
end
-local function like(M1, v)
+function pl.array2d.like(M1, v)
v = v or 0
r, c = pl.array2d.size(M1)
return pl.array2d.new(r,c,v)
end
-local function from_table(t) -- turns a labelled table to a 2d, label-free array
+function pl.array2d.from_table(t) -- turns a labelled table to a 2d, label-free array
t_new = {}
for k, v in pairs(t) do
if type(v) == 'table' then
@@ -150,7 +149,7 @@ local function from_table(t) -- turns a labelled table to a 2d, label-free array
return t_new
end
-local function toTeX(M, EL) --puts & between columns, can choose to end line with \\ if EL is true (end-line)
+function pl.array2d.toTeX(M, EL) --puts & between columns, can choose to end line with \\ if EL is true (end-line)
EL = EL or false
if EL then EL = '\\\\' else EL = '' end
return pl.array2d.reduce2(_1..EL.._2, _1..'&'.._2, M)..EL
@@ -158,31 +157,41 @@ end
-- -- -- -- -- -- --
--- add to array2d module
-pl.array2d['map_columns'] = map_columns
-pl.array2d['map_rows'] = map_rows
-pl.array2d['map_slice2'] = map_slice2
-pl.array2d['map_slice1'] = map_slice1
-pl.array2d['from_table'] = from_table
-pl.array2d['toTeX'] = toTeX
-pl.array2d['sortOP'] = sortOP
-pl.array2d['like'] = like
-- -- -- -- -- -- -- -- -- -- -- -- functions below extend the operator module
-local function strgt(a,b) return tostring(a) > tostring(b) end
-local function strlt(a,b) return tostring(a) < tostring(b) end
-pl.operator['strgt'] = strgt
-pl.operator['strlt'] = strlt
+function pl.operator.strgt(a,b) return tostring(a) > tostring(b) end
+function pl.operator.strlt(a,b) return tostring(a) < tostring(b) end
+
+
+-- -- -- -- string stuff
+local lpeg = require"lpeg"
+local P, R, S, V = lpeg.P, lpeg.R, lpeg.S, lpeg.V
+local number = P{"number",
+ number = (V"int" * V"frac"^-1 * V"exp"^-1) / tonumber,
+ int = V"sign"^-1 * (R"19" * V"digits" + V"digit"),
+ digits = V"digit" * V"digits" + V"digit",
+ digit = R"09",
+ sign = S"+-",
+ frac = P"." * V"digits",
+ exp = S"eE" * V"sign"^-1 * V"digits",
+ }
-local function gextract(s, pat) --extract a pattern from string, returns both
+local mt = getmetatable("") -- register functions with str
+
+
+function mt.__index.gnum(s)
+ return number:match(s)
+end
+
+function mt.__index.gextract(s, pat) --extract a pattern from string, returns both
local s_extr = ''
local s_rem = s
for e in s:gmatch(pat) do
@@ -192,7 +201,7 @@ local function gextract(s, pat) --extract a pattern from string, returns both
return s_extr, s_rem
end
-local function gfirst(s, t) -- get the first pattern found from a table of pattern
+function mt.__index.gfirst(s, t) -- get the first pattern found from a table of pattern
for _, pat in pairs(t) do
if string.find(s, pat) then
return pat
@@ -200,7 +209,7 @@ local function gfirst(s, t) -- get the first pattern found from a table of patte
end
end
-local function appif(S, W, B, O) --append W ord to S tring if B oolean true, otherwise O ther
+function mt.__index.appif(S, W, B, O) --append W ord to S tring if B oolean true, otherwise O ther
--append Word to String
if B then --if b is true
S = S .. W
@@ -211,12 +220,10 @@ local function appif(S, W, B, O) --append W ord to S tring if B oolean true, oth
return S
end
-local mt = getmetatable("") -- register functions with str
-mt.__index["gextract"] = gextract
-mt.__index["gfirst"] = gfirst
-mt.__index["app_if"] = appif
+-- -- -- -- -- math stuffs
+
function mod(a, b) -- math modulo, return remainder only
return a - (math.floor(a/b)*b)
end
@@ -226,9 +233,11 @@ function mod2(a) -- math modulo 2
end
function hasval(x) -- if something has value
- if (x == nil) or (x == false) or (x == 0) or (x == '') then
+ if (type(x) == 'function') then
+ return true
+ elseif (x == nil) or (x == false) or (x == 0) or (x == '') then
return false
- elseif (type(x) ~= 'number') or (type(x) ~= 'string') then
+ elseif (type(x) ~= 'boolean') and (type(x) ~= 'number') and (type(x) ~= 'string') then
if #x == 0 then
return false
else
@@ -241,59 +250,6 @@ end
--- testing here
-____zzz__ = [[
-function hasStrKey(T)
- --checks if a Table contains a string-type key
- local hasaStrKey = false
- for k, v in pairs(T) do --look through table pairs
- if type(k) == "string" then --if any string found, return true
- hasaStrKey = true
- break
- end
- end
- return hasaStrKey
-end
-
-
-function any()
- --todo go through table or list of args and return true of anything is something
-end
-
-function all()
- --todo go through table or list of args and return true of anything is something
-end
-
-
- --elseif x == {} then
- -- return false
-
-n = nil
-b = false
-z = 0
-e = ''
-t = {}
-
---s = 'a'
---n = 1
-
-
-if is(nil) then
- print('TRUE')
-else
- print('FALSE')
-end
-
---print({}=={})
---print(0.0==0)
-
-
-]]
-
-
-
-
-
@@ -343,8 +299,10 @@ function reset_bkt_cnt(n)
end
function add_bkt_cnt(n)
+ -- add open bracket n times, returns brackets
n = n or 1
_NumBkts = _NumBkts + n
+ return ('{'):rep(n)
end
function close_bkt_cnt()
@@ -361,7 +319,7 @@ end
--definition helpers -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
--- todo add this
+-- todo add and improve this
local function defcmd_nest(cs) -- for option if you'd like your commands under a parent ex. \csparent{var}
tex.print('\\gdef\\'..cs..'#1{\\csname '..var..'--#1--\\endcsname}')