7

I'm a little new to pseudocode, What does : mean in pseudocode?

For example:

X ← copy(C[s − a : s + len])
Laurel
  • 5,965
  • 14
  • 31
  • 57

3 Answers3

4

X ← copy(C[s − a : s + len])

From s - a to s + len.

Maroun
  • 94,125
  • 30
  • 188
  • 241
4

Since pseudocode is an informal description of code, any particular piece of pseudocode means whatever the author intended it to mean. Usually the meaning is either obvious from context or the author provides some kind of key to the symbols they use.

In this case, the colon appears to be a range operator. But, you should not take that to mean that it will always be a range operator in any other pseudocode that you run across.

Ferruccio
  • 98,941
  • 38
  • 226
  • 299
  • "Usually the meaning is ..." or the writer is using syntax similar to a specific language (which is usually a problem if the syntax doesn't clearly point to some meaning or similar syntax is used in many languages, as indicated in the question). – Bernhard Barker Mar 26 '14 at 13:29
2

COMPLEMENT:

As Ferruccio said, pseudocode is informal so it is interpreted according to the conventions that the writer uses or some conventions that are understandable for computer community members.

Nevertheless I give you here some examples to make it's meaning more clear for you in various situations :

  1. Block indicator

    foreach di in D :
     ...
    
  2. Range (like your case)

    for i in range (1 : 10) do
     ...
    
  3. Block indicator

    if (condition) :
    
  4. Block indicator

    function myFunc() :
    
  5. Synonym for "so that"

    sample from posterior S = {Theta(t) : t = 1,...,N}
    
  6. Concatenation of two matrices horizontally

    Z = X:Y
    

The bad news: there are even more different meanings for a simple colon!

Mohsen Kamrani
  • 7,177
  • 5
  • 42
  • 66