GEORGE (programming language): Difference between revisions

Content deleted Content added
wl, f. Needs more wikify though
wls
Line 3:
It was designed around a push-down pop-up stack for arithmetic operations, and employed [[reverse Polish notation]].
 
The language included loops[[loop (computing)|loop]]s, subroutines[[subroutine]]s, conditionals[[conditional (programming)|conditional]]s, vectors[[array data structure|vector]]s, and [[matrix (mathematics)|matrices]].
 
Algebraic expressions were written in reverse Polish notation; thus, <math>a + b</math> was written <code>a b +</code>, and similarly for the other arithmetic operations of subtraction, multiplication, and division.
Line 11:
Following the reverse Polish form, an assignment statement to evaluate the formula <math>y = ax^2 + bx + c</math> was written as <code>a x dup × × b x × + c + (y)</code>.
 
The computer evaluated the expression as follows: the values of <code>a</code>, then <code>b</code>, were pushed onto the top of the [[stack machine|accumulator stack]]; '<code>dup</code>' caused a copy of the top-most value (<code>x</code>) to be pushed onto the top of the accumulator stack; Multiply (<code>×</code>) caused the top two values, namely, <code>x</code> and <code>x</code>, to be removed (popped) and multiplied, returning the product to the top of the accumulator stack. The second multiply (<code>×</code>) then caused the top two values on the stack (namely, <code>a</code> and <code>x**2</code>) to be popped and multiplied, and the product (<code>a×x**2</code>) to be pushed onto the top of the accumulator stack. And so on the remaining components of the expression. The final operation, namely (<code>y</code>), returned the value of the expression to storage without changing the status of the accumulator stack.
 
Assuming that the value on the top of the accumulator stack was not required immediately, it would be removed (cleared) by using the operator (<code>;</code>).
 
The following program reads in eight values and forms their sum:
Line 37:
1, 10 P1 (a)
</pre>
: In the program, the first line is a vector read that reads in the ten values into a(1) through a(10).
: The second line introduces a loop to run though the ten values of j.
: The third line fetches a(j), duplicates it, multiplies those two values giving the square, and then stores it in a(j). Note the semicolon (;), which clears (or cancels) the top entry in the accumulator stack. Were this not done, the accumulator would gradually fill up with the squares of the values.
: The final line is a vector punch (i.e., print) to write out the ten squares.
 
{| class="wikitable" style="text-align: center; width: 200px; height: 200px;"