# In pseudo code what does := mean?

The section entitled Algorithmic Implementation has the following code:

``````// Return RC low-pass filter output samples, given input samples,
// time interval dt, and time constant RC
function lowpass(real[0..n] x, real dt, real RC)
var real[0..n] y
var real α := dt / (RC + dt)
y[0] := x[0]
for i from 1 to n
y[i] := α * x[i] + (1-α) * y[i-1]
return y
``````

what does := mean?

-
I learned that it was from philosophy and logic notation, which defines it as ":= defined to be" so x := 1 is x is defined to be 1. – Patrick Hughes Jan 19 '12 at 6:13
When I took AP computer science in 1990, we used Pascal as our learning language. I always pronouced `:=` as "becomes equal to". I actually prefer this over `=` and `==` since "=" in natural language is a comparison operator (or at least a statement of truth.) – TecBrat Feb 14 '14 at 14:05

:= is the assignment operator for languages that use single equals sign equality testing. The most well known of those languages is Pascal. Due to C's influence most languages switched to = for assignment and == for testing. Some older texts and authors that were trained in such styles use := for pseudocode. You sometimes see arrows <- as well for assignment.

From the article:

``````input: an array a of length n with array elements numbered 0 to n − 1

inc ← round(n/2)
while inc > 0 do:
for i = inc .. n − 1 do:
temp ← a[i]
j ← i
while j ≥ inc and a[j − inc] > temp do:
a[j] ← a[j − inc]
j ← j − inc
a[j] ← temp
inc ← round(inc / 2.2)
``````

Some modern languages use arrows for assignment; most notably R, which uses it for global assignment whilst using the single equals ( = ) for local assignment.

From Sebesta's Concepts of Programming Languages and the class notes of Dr. K. N. King we learn that the assignment standards go back much farther than C or Pascal. It appears that in 1958 when Algol was being designed, it was decided to use := for assignment. The commitee was composed of American and European representatives. Some of the Germans on the committee were familiar with Konrad Zuse's Plankalkul language (which was drafted during World War II but not published until 1972 and not implemented until 2005) and wanted the assignment to follow that language's proposed assignment method which was `b+c => a` where b+c is assigned to a. The committee changed this to =: on the grounds that the method of entering programs at the time called a keypunch, did not have a ">" to use. So they compromised on the equals colon. However, the Americans being familiar with FORTRAN (it didn't have lower case until 1990) wanted the assignment to operate to the left since that was how FORTRAN did it.

So they managed to get it changed to := instead and had the assignment operate toward the left rather than the right in the style of FORTRAN (being a known implemented language) rather than Plankalkul (a virtually unknown language outside of Germany and not implemented). Algol 60 strongly influenced all major subsequent imperative languages including Pascal and C. Thus Pascal kept ALGOL's syntax for assignment and both kept the lefthandedness of assignment.

ALGOL was designed to be easy to read and close to mathematical notation. It was the de facto (and basically de jure) standard for writing algorithms in journals for next 20+ years. Therefore, instructors and computer scientists educated from 1960 to around 1980 would have been familiar with that style of notation.

The release of the IBM 029 Keypunch in 1964 allowed for > and < characters, thus prompting their inclusion in C among others.

-
Apart from missing semicolons and function return type this code anyway looks like PASCAL, MODULA or some other Wirth language. – Ingo Aug 17 '11 at 10:27
most pseudo codes use `:=` for assignment. people with mathematical background will favor this, too. – oenone Aug 17 '11 at 10:55
Just to add that it is still very much used practically in PL/SQL. – Jalayn Aug 17 '11 at 11:39
don't know why, but left arrow as assignment just drives me mad 9 – shabunc Sep 22 '11 at 9:45
Pascal (and the rest of "the Wirth languages") got it from ALGOL, which got it from mathematical notation. – Mason Wheeler Jan 19 '12 at 4:06

Just a quick and pedantic note. Pseudocode is quite informal, so ":=" means only what you want it to mean. As others have said, specific languages such as Pascal use ":=" for assignment to avoid confusion with "=" for equality, whereas other languages use the combination of "=" and "==" for the same purpose.

As far as actual Pseudocode is concerned, you can use "=", "==", "equals", "is assigned to", ":=", "has", "receives", or whatever floats your boat, just so long as you are consistent, and the usage and context is within your pseudocode is clear.

-

I'm guessing it's assignment (I think it is the assignment operator in Delphi), so in y[0] := x[0] you're assigning the value of x[0] to y[0].

But AFAIK there's no such thing as a standard pseudo code, so in theory it could be anything :=).

-
That's what I thought too but I'm puzzled as to why they use := and not just = – user33716 Aug 17 '11 at 10:09
@loudsight: Because `=` already has a very different meaning: equality. Using an operator which already has a well-understood meaning for something different would be extremely stupid. – Jörg W Mittag Aug 17 '11 at 10:20
@Jörg W Mittag Well I guess it depends on who the intended audience is. I would imagine for most developers (Java, C/C++, etc..) = means assignment. – user33716 Aug 17 '11 at 11:36
@loudsight: Most developers weren't even born, when the first pseudo-code was written. Back then, it was mostly people from a strong mathematical background, who wrote down algorithms, which makes `:=` the natural choice, because in mathematical notation `x := v` means "let `x` be `v`" as opposed to `x = v`, which means "`x` equals `v`" and would therefore cause confusion. – back2dos Aug 17 '11 at 12:16
If there were a standard pseudo code, we would see lots of pseudo pseudo code. – user1249 Dec 10 '11 at 9:45

It usually means the same thing it means in math: assignment.

-
There is no such thing as "assignment" in math to my knowledge. – Ingo Aug 17 '11 at 10:26
in mathematics, `:=` usually means "is defined as" or "is equal by definition". – oenone Aug 17 '11 at 10:58
@Ingo: "write the bit pattern for the value of expression x to a memory location that is named y" is completely different from an assignment in programming languages. What you describe is a possible implementation of executing assignment statements. – back2dos Aug 17 '11 at 12:07
@Ingo: I disagree. Let alone the fact, that in the case of properties, an assignment yields a call, and the fact that a vast part of code is executed in virtual machines or by interpreters, rather than directly on the "current architecture", even assignments to variables need not result in such an operation, due to optimization. With few exceptions, a language should be used according to its specifications and not based on some assumptions about its implementation. All you can really say about assignments to variables is that the variable named y is rebound to the value of the expression x. – back2dos Aug 17 '11 at 13:49
@Ingo: No, it's not nonsense. Compiling `x := 1; y := 2; if (x = 1) y := 3` as if it just were `y := 3` is a reasonable optimization (assuming x is not used later on). Of 3 assignments 2 are implemented by means of static analysis. Your "definition" of assignments is a blanket statement, that simply doesn't hold without numerous assumptions a definition of this term should not have to depend upon. – back2dos Aug 17 '11 at 14:32