From 0e78a52b61b7713021186d53a5d5f6b2d8cb745b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Fri, 21 Jan 2022 14:37:26 +0100 Subject: [PATCH] add macro to flatten inheritance relation --- doc/environments/groupthm/groupthm.dtx | 38 ++++++++++++++++++++++++-- doc/environments/groupthm/groupthm.sty | 23 ++++++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/doc/environments/groupthm/groupthm.dtx b/doc/environments/groupthm/groupthm.dtx index 0002ac8..6cbcf0d 100644 --- a/doc/environments/groupthm/groupthm.dtx +++ b/doc/environments/groupthm/groupthm.dtx @@ -1878,8 +1878,42 @@ % \end{macro} % % -% -% +% +% \begin{macro}{\@@_flatten_groups_hierarchy:nN} +% \begin{syntax} +% \cs{@@_flatten_groups_hierarchy:n}\marg{theorem groups}\marg{clist} +% \end{syntax} +% +% Expects a comma separated list of \meta{theorem group}s. +% The inheritance relation is flattened, and the set of +% obtained theorem groups is stored in \meta{clist} +% +% \begin{macrocode} +\cs_new:Npn \@@_push_tmpa_seq:n #1 + { + \seq_push:Nn \l_tmpa_seq { #1 } + } +\cs_new:Npn \@@_flatten_groups_hierarchy:nN #1 #2 + { + \clist_clear:N #2 + \seq_set_from_clist:Nn \l_tmpa_seq { #1 } + \bool_until_do:nn + { + \seq_if_empty_p:N \l_tmpa_seq + } + { + \seq_pop:NN \l_tmpa_seq \l_tmpa_tl + \clist_if_in:NVF #2 \l_tmpa_tl + { + \clist_put_left:NV #2 \l_tmpa_tl + \clist_map_function:cN + { g_@@_parents_group__ \l_tmpa_tl __clist } + \@@_push_tmpa_seq:n + } + } + } +% \end{macrocode} +% \end{macro} % % % \subsection{Iterating over powersets} diff --git a/doc/environments/groupthm/groupthm.sty b/doc/environments/groupthm/groupthm.sty index cd68056..b6cddf7 100644 --- a/doc/environments/groupthm/groupthm.sty +++ b/doc/environments/groupthm/groupthm.sty @@ -379,6 +379,29 @@ { \groupthm_add_parent:nn { #1 } { #2 } } +\cs_new:Npn \__groupthm_push_tmpa_seq:n #1 + { + \seq_push:Nn \l_tmpa_seq { #1 } + } +\cs_new:Npn \__groupthm_flatten_groups_hierarchy:nN #1 #2 + { + \clist_clear:N #2 + \seq_set_from_clist:Nn \l_tmpa_seq { #1 } + \bool_until_do:nn + { + \seq_if_empty_p:N \l_tmpa_seq + } + { + \seq_pop:NN \l_tmpa_seq \l_tmpa_tl + \clist_if_in:NVF #2 \l_tmpa_tl + { + \clist_put_left:NV #2 \l_tmpa_tl + \clist_map_function:cN + { g__groupthm_parents_group__ \l_tmpa_tl __clist } + \__groupthm_push_tmpa_seq:n + } + } + } \clist_new:N \l__powerset_copied_clist \seq_new:N \l__powerset_saved_seq \cs_generate_variant:Nn \clist_remove_all:Nn { N V }