add macro to flatten inheritance relation

This commit is contained in:
Maximilian Keßler 2022-01-21 14:37:26 +01:00
parent 7f1132b898
commit 0e78a52b61
2 changed files with 59 additions and 2 deletions

View file

@ -1879,7 +1879,41 @@
%
%
%
% \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}

View file

@ -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 }