I would like to find a pseudocode package that support the possibility to wrote a comment at the right side of a if and that it wont be between { } but rather at the right side of the page, after a symbol.

if x < p {     .} then


something like this:

if (x < p)         \blacktriangleright x is a ...


my code:

 \documentclass[]{scrbook}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\begin{document}
\begin{algorithm}
\caption{Influx}
\label{influx}
\begin{algorithmic}[1]
\REQUIRE $p \in [0,1]$, $G$
\ENSURE None
\FOR{$i = 0 \to 2^d-1$}
\IF{$n(\nu_i) = 0$}
\IF{ $x < p$ \COMMENT{ $x$ is a normal distribution number in the range of $[0,1]$}}
\STATE Occupy $v_i$ site with probablility $p$
\ENDIF
\ENDIF
\ENDFOR
\end{algorithmic}
\end{algorithm}


Any ideas?

-
Welcome to TeX.sx! Please crop your images to avoid large margins which makes the question harder to read. –  Martin Scharrer Jun 23 '11 at 16:46
@Martin, you was a bit faster then me ;) as i cam to fix it, it was already done –  Eagle Jun 23 '11 at 16:58
Yes, I'm quick in fixing some things. –  Martin Scharrer Jun 23 '11 at 16:59

To achieve your desire, it would be necessary to make some (as far as I could tell) major changes in the algorithmic package. One possibility is to use the algorithmicx package instead. A little example

\documentclass[]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{algorithm,algorithmicx,algpseudocode}
\usepackage{amssymb}

%\algrenewcommand{\algorithmiccomment}[1]{\hfill$\blacktriangleright$ #1}

\begin{document}
\begin{algorithm}
\caption{Influx}
\label{influx}
\begin{algorithmic}[1]
\Require $p \in [0,1]$, $G$
\Ensure None \Comment{a test comment}
\For{$i = 0 \to 2^d-1$}\Comment{another test comment}
\If{$n(\nu_i) = 0$}
\If{ $x < p$}  \Comment{$x$ is a normal distribution number in the range of $[0,1]$}
\State Occupy $v_i$ site with probablility $p$
\EndIf
\EndIf
\EndFor
\end{algorithmic}
\end{algorithm}

\end{document}


Here's the result:

Uncommenting the line with \algrenewcommand you'll get a black triangle for the comments.

-
+1 … algorithmicx is far superior to all the other pseudo-code packages. It wins hands down. –  Konrad Rudolph Jun 23 '11 at 18:29
It is exactly what i wanted, thanks –  Eagle Jun 23 '11 at 21:17