Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'd like compute cosets using the permute package.

Here's what I have so far:

\documentclass{article}
\usepackage{expl3,xparse,permute}

\ExplSyntaxOn
% Create a new command to compute the right coset Hg, taking in the element and the set
%% Clear a local clist for use
%% For each element in the set (#2)
%%% Set the current permutation to the identity
%%% Set the current permutation to the one we are looking at in the iteration
%%% Compose it with the element we were given in #1 on the right
%% Type the clist; Print the clist
\NewDocumentCommand \PMTCosetR { m m } {
  \clist_clear:N \l_tmpa_clist
  \clist_map_inline:nn { #2 } {
    \pmtid          \pmtdo{##1}      \pmtdo{#1}  % compressed to avoid scrollbar on TeX.SX
    \clist_put_right:NV \l_tmpa_clist \pmtprint
  }
  \clist_show:N \l_tmpa_clist
  \ensuremath{\Big\{\clist_use:Nn \l_tmpa_clist {,}\Big\}}
}
\ExplSyntaxOff

\begin{document}
\PMTCosetR{(12)}{(),(123),(132)} \par
Expecting values:
\begin{itemize}
\item \pmt{(12)()}
\item \pmt{(12)(123)}
\item \pmt{(12)(132)}
\end{itemize}
\end{document}

The critical problem is actually what is being put into the list:

The comma list \l_tmpa_clist contains the items (without outer braces):
>  {\pmt@GetPrintArgs {\pmt@PrintPmt \pmt@curr }}
>  {\pmt@GetPrintArgs {\pmt@PrintPmt \pmt@curr }}
>  {\pmt@GetPrintArgs {\pmt@PrintPmt \pmt@curr }}.

Unfortunately, changing the appropriate argspec (V|ox) results in an error:

ERROR: Undefined control sequence.

--- TeX said ---
\pmt@GetPrintArgs #1->\let \pmt@order 
                                      \pmtprintorder \def \pmt@next {#1}\@if...
l.27 \PMTCosetR{(12)}{(),(123),(132)}

I figure there must be a way to control how many times \pmtprint is expanded, since one expansion is obviously not cutting it. Can I expand it exactly twice? Three times? As many times 'as necessary', whatever that means?

share|improve this question
    
It's not clear to me what the 'bigger picture' aim is here. The \pmtprint command isn't expandable, so you can't get the 'results' and store them. –  Joseph Wright Nov 24 '13 at 10:26
    
It's not only a question of expansions: note that the error happens at \let. –  egreg Nov 24 '13 at 11:16

1 Answer 1

up vote 5 down vote accepted

You have to compute the composition, so why trying to do it when building the clist to deliver?

I use a sequence, because it's more efficient.

\documentclass{article}
\usepackage{expl3,xparse,permute}

\ExplSyntaxOn
\NewDocumentCommand \PMTCosetR { m m }
 {
  \seq_clear:N \l_tmpa_seq
  \clist_map_inline:nn { #2 }
   { \seq_put_right:Nn \l_tmpa_seq { \pmt{#1##1} } }
  \bigl\{\seq_use:Nn \l_tmpa_seq {,}\bigr\}
}
\ExplSyntaxOff

\begin{document}
$\PMTCosetR{(12)}{(),(123),(132)}$

Expecting values:
\begin{itemize}
\item \pmt{(12)()}
\item \pmt{(12)(123)}
\item \pmt{(12)(132)}
\end{itemize}
\end{document}

enter image description here

share|improve this answer
    
As I read the question, I thought you would provide a new expl3-package ;-) –  Marco Daniel Nov 24 '13 at 11:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.