I try to implement the currying function , and I start from implement the following :
\myproc<=b<=awill printa \mapsto b \mapsto {\rm output}\myproc<=bwill print{\bf a} \mapsto b \mapsto {\rm output}\myproc<<=awill printa \mapsto {\bf b} \mapsto {\rm output}the next step is to make
\myproc<<=abe the function that acceptsbas input (e.g.\myproc<<=a<=boutputs\myproc<=b<=a)
where the \bf stands for the default value .
However when I replace the a / b by x_1 / and x_2 , something undesired happened :
Here is the MWE : https://www.overleaf.com/9672474965wszpvxnkwkpr#bdc9bc
Here is the code in case you cannot access to the overleaf link :
\documentclass{article} \usepackage{amsmath} \usepackage{amssymb} \usepackage{amsfonts} \usepackage{mathtools} \usepackage{tikz} \begin{document} \makeatletter \def\myproc<{% \@ifnextchar <% {\myproc@NopB} {\myproc@YopB} } \def\myproc@NopB<=#1{% \myproc@YopB@YopA{{\bf x}_2}<={#1}% } \def\myproc@YopB=#1{%<=#2 \@ifnextchar <% {\myproc@YopB@YopA#1}% myproc <=b<=a myproc@YopB =b<=a myproc@YopB@YopA b<=a {\myproc@YopB@NopA#1}% myproc <=b myproc@YopB =b myproc@YopB@NopA b } \def\myproc@YopB@NopA#1{% \myproc@YopB@YopA{#1}<={{\bf x}_1}% } \def\myproc@YopB@YopA#1<=#2{ {#2} \mapsto {#1} \mapsto {\rm output}% } \makeatother % \myproc@NopB \(\myproc<<={x_1}\)\par \(\myproc<={x_2}\)\par \(\myproc<={x_2}<={x_1}\) \vspace{10pt} The desire result should be\par \(x_1\mapsto {\bf x}_2\mapsto {\rm output}\)\par \({\bf x}_1\mapsto x_2\mapsto {\rm output}\)\par \(x_1 \mapsto x_2 \mapsto {\rm output}\) \end{document} 

\NewDocumentCommandmight simplify this problem