texlive[72566] Master/texmf-dist: commalists-tools (16oct24)

commits+karl at tug.org commits+karl at tug.org
Wed Oct 16 21:33:52 CEST 2024


Revision: 72566
          https://tug.org/svn/texlive?view=revision&revision=72566
Author:   karl
Date:     2024-10-16 21:33:52 +0200 (Wed, 16 Oct 2024)
Log Message:
-----------
commalists-tools (16oct24)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/commalists-tools/commalists-tools-doc.pdf
    trunk/Master/texmf-dist/doc/latex/commalists-tools/commalists-tools-doc.tex
    trunk/Master/texmf-dist/tex/latex/commalists-tools/commalists-tools.sty

Modified: trunk/Master/texmf-dist/doc/latex/commalists-tools/commalists-tools-doc.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/commalists-tools/commalists-tools-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/commalists-tools/commalists-tools-doc.tex	2024-10-16 19:33:28 UTC (rev 72565)
+++ trunk/Master/texmf-dist/doc/latex/commalists-tools/commalists-tools-doc.tex	2024-10-16 19:33:52 UTC (rev 72566)
@@ -27,8 +27,8 @@
 \hypersetup{pdfborder=0 0 0}
 \usepackage[margin=2cm]{geometry}
 \setlength{\parindent}{0pt}
-\def\TPversion{0.1.1}
-\def\TPdate{10/10/2024}
+\def\TPversion{0.1.2}
+\def\TPdate{16/10/2024}
 \usepackage{tcolorbox}
 \usepackage{pgffor}
 \tcbuselibrary{breakable,skins,hooks,listingsutf8}
@@ -49,7 +49,7 @@
 	keywordstyle={\color{violet}},%
 	classoffset=2,%
 	alsoletter={-},%
-	morekeywords={\sortasclist,\sortdeslist,\addvalinlist,\removevalinlist,\boolvalinlist,\xintifvalinlist,\countvalinlist,\minoflist,\maxoflist,\meanoflist,\sumoflist,\prodoflist,\reverselist,\getvaluefromlist,\lenoflist,\getvaluefromlist},%
+	morekeywords={\sortasclist,\sortdeslist,\addvalinlist,\removevalinlist,\boolvalinlist,\xintifvalinlist,\countvalinlist,\minoflist,\maxoflist,\meanoflist,\sumoflist,\prodoflist,\reverselist,\getvaluefromlist,\lenoflist,\getvaluefromlist,\definelist,\countvalindeflist,\lenofdeflist,\meanofdeflist,\sumofdeflist,\prodofdeflist,\getvaluefromdeflist},%
 	keywordstyle={\color{green!50!black}},%
 	classoffset=3,%
 	morekeywords={},%
@@ -79,7 +79,7 @@
 		keywordstyle={\color{violet}},%
 		classoffset=2,%
 		alsoletter={-},%
-		morekeywords={\sortasclist,\sortdeslist,\addvalinlist,\removevalinlist,\boolvalinlist,\xintifvalinlist,\countvalinlist,\minoflist,\maxoflist,\meanoflist,\sumoflist,\prodoflist,\reverselist,\getvaluefromlist,\lenoflist,\getvaluefromlist},%
+		morekeywords={\sortasclist,\sortdeslist,\addvalinlist,\removevalinlist,\boolvalinlist,\xintifvalinlist,\countvalinlist,\minoflist,\maxoflist,\meanoflist,\sumoflist,\prodoflist,\reverselist,\getvaluefromlist,\lenoflist,\getvaluefromlist,\definelist,\countvalindeflist,\lenofdeflist,\meanofdeflist,\sumofdeflist,\prodofdeflist,\getvaluefromdeflist},%
 		keywordstyle={\color{green!50!black}},%
 		classoffset=3,%
 		morekeywords={},%
@@ -216,7 +216,7 @@
 
 The idea is to propose "reusage" of lists with \texttt{listofitems} or other commands, for example.
 
-\section{The Macros}
+\section{The individual macros}
 
 \subsection{Global usage}
 
@@ -238,13 +238,13 @@
 
 \hfill\textbf{All engines \TeX\ are compatible with this package.}\hfill~
 
-\subsection{The macros for calculing}
+\subsection{The macros for calculating}
 
 \begin{DemoCode}{listing only}
 %getting length of list, only printing
 \lenoflist*{list}
 %storing length of list into macro (\resmylen by default)
-\lenoflist*{list}
+\lenoflist{list}
 %getting min of list, only printing
 \minoflist*{list}
 %storing min of list into \macro (\resmin by default)
@@ -435,8 +435,44 @@
 
 \pagebreak
 
+\section{Macros for already processed lists}
+
+In order to speed up the process, it's possible to "define" a list (processed with \texttt{listofitems}) and the to call specific macros.
+
+\begin{DemoCode}{listing only}
+%define a list, to be processed by listofitems
+\definelist{rawlist}{processed list}
+
+%Specific macros (same specs as above)
+\lenofdeflist(*){processed list, without \ !}[\macro]
+\countvalindeflist(*){val}{processed list, without \ !}[\macro]
+\meanofdeflist(*){processed list, without \ !}[\macro]
+\sumofdeflist(*){processed list, without \ !}[\macro]
+\prodofdeflist(*){processed list, without \ !}[\macro]
+\getvaluefromdeflist(*){processed list, without \ !}{index}[\macro]
+\end{DemoCode}
+
+\begin{DemoCode}{}
+%define a list, to be processed by listofitems
+\definelist{1,4,5,6,7,8,9,19,9,9,10}{\mydeflist}\showitems{\mydeflist}
+
+%Specific macros
+\lenofdeflist*{mydeflist}\\
+\getvaluefromdeflist*{mydeflist}{5}\\
+\countvalindeflist*{9}{mydeflist}\\
+\meanofdeflist*{mydeflist}\\
+\sumofdeflist*{mydeflist}\\
+\prodofdeflist*{mydeflist}
+\end{DemoCode}
+
+If the list needs to be "modified" (add, remove, reverse) the best is to use individual macros, and after use \textit{define} and specific macros :-)
+
+\pagebreak
+
 \section{History}
 
+\texttt{0.1.2: Alternative macros for already treated lists}
+
 \texttt{0.1.1: Compatibility with decimals, len of list, get value}
 
 \texttt{0.1.0: Initial version}

Modified: trunk/Master/texmf-dist/tex/latex/commalists-tools/commalists-tools.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/commalists-tools/commalists-tools.sty	2024-10-16 19:33:28 UTC (rev 72565)
+++ trunk/Master/texmf-dist/tex/latex/commalists-tools/commalists-tools.sty	2024-10-16 19:33:52 UTC (rev 72566)
@@ -2,9 +2,10 @@
 % licence    : Released under the LaTeX Project Public License v1.3c or later, see http://www.latex-project.org/lppl.txtf
 
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{commalists-tools}[2024/10/10 0.1.1 Basic operations for numeral comma separated lists]
+\ProvidesPackage{commalists-tools}[2024/10/16 0.1.2 Basic operations for numeral comma separated lists]
 
 %------History
+% 0.1.2	New versions with already traited lists
 % 0.1.1	Sorting with decimals (!)
 % 0.1.0	Initial version
 
@@ -61,6 +62,12 @@
 		}%
 }
 
+\NewDocumentCommand\definelist{ m m }{%
+	%1 = raw list
+	%2 = traited list with listofitems
+	\readlist*#2{#1}%
+}
+
 \NewDocumentCommand\removevalinlist{ s m m }{%
 	\readlist*\tmplistread{#3}%
 	\xdef\tmpresremovelist{}%
@@ -111,6 +118,22 @@
 		}%
 }
 
+\NewDocumentCommand\countvalindeflist{ s m m O{\rescount} }{%
+	%\readlist*\tmplistread{#3}%
+	\xdef#4{0}%
+	\xintFor* ##1 in {\xintSeq{1}{\csname#3len\endcsname}}\do{%
+		\xintifboolexpr{ \csname#3\endcsname[##1] == #2}%
+		{%
+			\xdef#4{\fpeval{#4+1}}%
+		}%
+		{}%
+	}%
+	\IfBooleanT{#1}%if star := just printing // if not, storing
+		{%
+			#4%
+		}%
+}
+
 \NewDocumentCommand\minoflist{ s m O{\resmin} }{%
 	\IfBooleanTF{#1}%
 		{%
@@ -144,6 +167,19 @@
 		}%
 }
 
+\NewDocumentCommand\meanofdeflist{ s m O{\resmean} }{%
+	\xdef#3{0}%
+	%\readlist*\tmpmeanlist{#2}%
+	\xintFor* ##1 in {\xintSeq{1}{\csname#2len\endcsname}}\do{%
+		\xdef#3{\fpeval{#3+\csname#2\endcsname[##1]}}%
+	}%
+	\xdef#3{\fpeval{(#3)/\csname#2len\endcsname}}%
+	\IfBooleanT{#1}%if star := just printing // if not, storing
+		{%
+			#3%
+		}%
+}
+
 \NewDocumentCommand\sumoflist{ s m O{\ressum} }{%
 	\xdef#3{0}%
 	\readlist*\tmpsumlist{#2}%
@@ -156,6 +192,18 @@
 		}%
 }
 
+\NewDocumentCommand\sumofdeflist{ s m O{\ressum} }{%
+	\xdef#3{0}%
+	%\readlist*\tmpsumlist{#2}%
+	\xintFor* ##1 in {\xintSeq{1}{\csname#2len\endcsname}}\do{%
+		\xdef#3{\fpeval{#3+\csname#2\endcsname[##1]}}%
+	}%
+	\IfBooleanT{#1}%if star := just printing // if not, storing
+		{%
+			#3%
+		}%
+}
+
 \NewDocumentCommand\prodoflist{ s m O{\resprod} }{%
 	\xdef#3{1}%
 	\readlist*\tmpprodlist{#2}%
@@ -168,6 +216,18 @@
 		}%
 }
 
+\NewDocumentCommand\prodofdeflist{ s m O{\resprod} }{%
+	\xdef#3{1}%
+	\readlist*\tmpprodlist{#2}%
+	\xintFor* ##1 in {\xintSeq{1}{\csname#2len\endcsname}}\do{%
+		\xdef#3{\fpeval{(#3)*\csname#2\endcsname[##1]}}%
+	}%
+	\IfBooleanT{#1}%if star := just printing // if not, storing
+		{%
+			#3%
+		}%
+}
+
 \NewDocumentCommand\reverselist{ s m O{\resrevlist} }{%
 	\readlist*\tmpreverselist{#2}%
 	\xdef#3{\tmpreverselist[-1]}%
@@ -186,6 +246,12 @@
 	\IfBooleanT{#1}{#4}%
 }
 
+\NewDocumentCommand\getvaluefromdeflist{ s m m O{\resmyelt} }{%
+	%\readlist*\tmpreadlist{#2}%
+	\xdef#4{\csname#2\endcsname[#3]}%
+	\IfBooleanT{#1}{#4}%
+}
+
 \NewDocumentCommand\lenoflist{ s m O{\resmylen} }{%
 	\readlist*\tmpreadlist{#2}%
 	\xdef#3{\tmpreadlistlen}%
@@ -192,4 +258,10 @@
 	\IfBooleanT{#1}{#3}%
 }
 
+\NewDocumentCommand\lenofdeflist{ s m O{\resmylen} }{%
+	%\readlist*\tmpreadlist{#2}%
+	\xdef#3{\csname#2len\endcsname}%
+	\IfBooleanT{#1}{#3}%
+}
+
 \endinput
\ No newline at end of file



More information about the tex-live-commits mailing list.