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 }