I want to use the etoolbox package to manage some loop contingencies over a counting index. In particular, I'd like to do something different on the first and last times through the loop.
Now I can formulate ways to do that, for example in this MWE. In the first case, I use a nested \ifboolexpr whereas in the second example, I set up an arcane switching system for toggles. Both of these approaches accomplish the underlying goal...
\documentclass{article}
\usepackage{etoolbox}
\newcounter{index}%
\begin{document}
\def\LAST{10}
\noindent%
\setcounter{index}{0}%
\whileboolexpr{test {\ifnumcomp{\theindex}<{\LAST}}}{%
\stepcounter{index}%
\ifboolexpr{test {\ifnumcomp{\theindex}{=}{1}}}%
{NOT\\}%
{\ifboolexpr{test {\ifnumcomp{\theindex}{=}{\LAST}}}%
{NOT\\}%
{\theindex\\}%
}%
}
\newtoggle{flag}
\noindent%
\setcounter{index}{0}%
\togglefalse{flag}%
\whileboolexpr{test {\ifnumcomp{\theindex}<{\LAST}}}{%
\stepcounter{index}%
\ifboolexpr{test {\ifnumcomp{\theindex}{=}{\LAST}}}{%
\togglefalse{flag}}{}%OFF FOR LAST COLUMN
\iftoggle{flag}{\theindex\\}{NOT\\}%
\toggletrue{flag}% ON FOR COLUMNS 2 TO \LAST-1
}%
\end{document}

However, the documentation leads me to believe that I should be able to use a Boolean and or or to accomplish this contingency with a single \ifboolexpr. And yet, I have been unable to construct such a syntax to do so. Is there a way, using the etoolbox syntax, to perform a single "if" check to determine if this is "the first excursion OR the \LAST excursion" through the loop, or alternately, if this is "not the first excursion AND not the \LAST excursion" through the loop?
