# Immutable functions in latex3? [closed]

Imagine we have a nonempty sequence named \l_tmpa_seq. We want to assign a name \l_tmpb_seq a value which is the result of invoking a function like

\int_eval:n {#1 + 1}


on every member of the sequence.

So take

\seq_set_eq:Nx \l_tmpb_seq  { \l_process_cs:N \l_tmpa_seq }


where

\cs_new_protected:Npn \l_process_cs:N #1
{
% Assign #1 to \l_name_seq
% Process the sequence \l_name_seq
% ...
% Leave / return the sequence \l_name_seq
}


and (for brevity; might be a custom function instead)

\cs_generate_variant:Nn \seq_set_eq:NN { Nx }


For now I resort to

1. mutating a second argument passed to such a function or
2. invoking \seq_use:Nn \l_name_seq {some_delimiter} as a return statement in an imperative language to serialize the result and invoking \seq_set_split:Nnn \l_another_seq {#1} {some_delimiter} as an assignment statement.

The first approach I would like to avoid completely, whereas the second is cumbersome but admits syntactic constructs like

\cs_return:N \l_name_seq


which could be done in a monadic fashion and

\seq_let:Nx \l_another_seq {\l_someFunction:N #1}


which I will implement to see how it works.

How do you return, serialize, evaluate the result of a function when assigning it to a variable outside that scope?

## closed as unclear what you're asking by egreg, Gonzalo Medina, user13907, Sean Allred, Paul GaboritJul 4 '15 at 23:31

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• Isn't it \seq_set_map:NNn? – egreg Mar 19 '15 at 11:47
• Welcome to TeX-sx! At the moment, I'm struggling to understand the question here: I think something like 'How do I arrange \l_tmpb_seq to contain the result of applying some function to each element of \l_tmpa_seq?' but I am far from certain. Could you perhaps add a 'non-programmers' explanation as most of us don't have formal backgrounds in the area! – Joseph Wright Mar 19 '15 at 11:48
• @egreg I'd forgotten we had that one :-) – Joseph Wright Mar 19 '15 at 11:52
• BTW, something like \cs_generate_variant:Nn \seq_set_eq:NN { Nx } is definitely wrong as the base argument for x is n, whereas the only variant valid for N is c. – Joseph Wright Mar 19 '15 at 12:16
• @egreg: Wow, I didn't look through the "Candidates" section of the manual (Sep 15, 2014). This may be exactly what I need. – user74514 Mar 19 '15 at 13:42