[Tex/LaTex] do-while loop in pseudo code


The algorithmic package lets me make a while loop as

  \While{$u\neq v$}
    \State Something

which results in a

while(u is not v) do 
end while 

How can I make a do-while loop which result in

while(u is not v)

(Sorry for the lack of output. I don't know how to add that to my question. I hope the question and the intention is clear enough) I use document class memoir and packages algpseudocode and algorithm.

Best Answer

You have to define the do-while construct yourself; see below.

Note: you tagged your question with algorithmicx, not algorithmic, so I produced an answer using the algorithmicx package.

enter image description here


\algdef{SE}[DOWHILE]{Do}{doWhile}{\algorithmicdo}[1]{\algorithmicwhile\ #1}%

    \State Something
  \doWhile{$u \neq v$} % <--- use \doWhile for the "while" at the end