diff options
author | Karl Berry <karl@freefriends.org> | 2021-11-08 23:22:10 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-11-08 23:22:10 +0000 |
commit | 1acf622594ee5da07939ea1d0af013af8eff10aa (patch) | |
tree | f42c7724f05101ebd4ba978682a75a6e721d460c /Master/texmf-dist/tex/luatex/penlight/penlightextras.lua | |
parent | 0aeb22a660c5212cd5597d3c6544bcbd3f81524d (diff) |
penlight (9nov21)
git-svn-id: svn://tug.org/texlive/trunk@61004 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex/penlight/penlightextras.lua')
-rw-r--r-- | Master/texmf-dist/tex/luatex/penlight/penlightextras.lua | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/Master/texmf-dist/tex/luatex/penlight/penlightextras.lua b/Master/texmf-dist/tex/luatex/penlight/penlightextras.lua index f612bd3370f..13d0ab5817c 100644 --- a/Master/texmf-dist/tex/luatex/penlight/penlightextras.lua +++ b/Master/texmf-dist/tex/luatex/penlight/penlightextras.lua @@ -2,17 +2,22 @@ local pl = _G['penlight'] or _G['pl'] -- penlight for this namespace is pl local bind = bind or pl.func.bind +-- some bonus string operations, % text operator, and functional programmng +pl.stringx.import() +pl.text.format_operator() +pl.utils.import('pl.func') + function help_wrt(s1, s2) -- helpful printing, makes it easy to debug, s1 is object, s2 is note local wrt = wrt or texio.write_nl local wrt = wrt or print s2 = s2 or '' - wrt('\nvvvvv '..s2) + wrt('\nvvvvv '..s2..'\n') if type(s1) == 'table' then wrt(pl.pretty.write(s1)) else wrt(tostring(s1)) end - wrt('^^^^^\n') + wrt('\n^^^^^\n') end @@ -129,7 +134,7 @@ local function like(M1, v) return pl.array2d.new(r,c,v) end -function from_table(t) -- turns a labelled table to a 2d, label-free array +local function 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 @@ -145,7 +150,7 @@ function from_table(t) -- turns a labelled table to a 2d, label-free array return t_new end -function toTeX(M, EL) --puts & between columns, can choose to end line with \\ if EL is true (end-line) +local function 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 @@ -221,10 +226,9 @@ function mod2(a) -- math modulo 2 end function hasval(x) -- if something has value - -- todo check for Lists, other penlight objects if (x == nil) or (x == false) or (x == 0) or (x == '') then return false - elseif type(x) == 'table' then + elseif (type(x) ~= 'number') or (type(x) ~= 'string') then if #x == 0 then return false else |