I have to write some algorithm in pseudocode for a paper. For this I have the "$\leftarrow$" to assign a value.

$x \leftarrow y^2$

now I want to write a method which adds to the variable. In normal Python code I would write x += 1 for this. Is there a style convention how to layout this in pseudo-code in a paper? I dont really like the redundance of $x \leftarrow x+1$.

  • 1
    $\begingroup$ $x \leftarrow x + 1$ is perfectly fine and commonly seen. $\endgroup$
    – orlp
    Commented Aug 21, 2020 at 21:43
  • 1
    $\begingroup$ yeah... but I have a lot of indexes and not much space... for example something like $\partial_i L^{ins} \leftarrow \partial_i L^{ins} + f_an_cy^{param}$ $\endgroup$
    – cagcoach
    Commented Aug 21, 2020 at 21:46

1 Answer 1


The +=et al are C shortcuts, adopted by many languages. Most anyone should understand them.

Then again, this is (pseudo)code, you certainly can make up you own variant. Just make sure to define clearly what any not-so-standard constructions mean (I'd go for += and so on, but then again, I'm a C fan...). But make sure to be consistent, i.e., use = for assignment and += for your operation, don't mix it with e.g. $\leftarrow$, and state that you'll use C notation for assignments.

Whatever you do, always keep in sight that the objective is understanding by your gentle reader, not extreme rigour or algorithmic details.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.