## Pascal

A programming language initially developed for teaching programming by Niklaus Wirth at ETH Zürich.

Pascal is a procedural language, similar to C; it is a descendant of Algol, designed in reaction to the complexity of the Algol-68 specification.

One noticeable difference to Algol is in how types are specified. In Pascal complex types are constructed from simpler types, whereas in Algol (and C, sigh) the syntax is the other way round -- an object of a composite type is picked apart until one gets to the simple type within. Cf.

```  var A : array [0..9] of integer;  (* Pascal *)
int A;  /* C */```

(C itself also has much in common with macro-assemblers, but counts in the taxonomy of computer languages as a member of the "Algol family". See e.g. [1 ].)

Pascal descendants include: Delphi Pascal, Modula 2, Modula 3 [4 ], Oberon, Oberon/2 [3 ], Component Pascal [2 ] and Free Pascal.

See http://www.xploiter.com/mirrors/pascal/default.htm for a self-paced learning module on Pascal programming.

pascal on the Tcl'ers Chat is Pascal Scheffers

The language was named in honor to the French philosopher and mathematician Blaise Pascal, who is also known for the Pascal Triangle. Here's Tcl code that produces the next row of the triangle, given any row:

``` proc pascal {{lastrow ""}} {
set res 1
foreach a [lrange \$lastrow 1 end] b \$lastrow {
lappend res [expr \$a+\$b]
}
set res
} ;# RS
% pascal
1
%pascal 1
1 1
% pascal {1 1}
1 2 1
% pascal {1 2 1}
1 3 3 1
% pascal {1 3 3 1}
1 4 6 4 1```

Note that in the last foreach step, a is "" (because the shorter list has ended). expr evaluates the string +1, which returns the final 1. But the expression must not be braced, otherwise it would raise an error by expr's parser, which would not take "" for a summand...

KBK: The numbers in Pascal's triangle are, of course, the binomial coefficients. Tcllib has a robust ::math::combinatorics::choose procedure for computing them, even for large and fractional arguments.

AM See also: Pascal's triangle - as it deserves its own page :)

Pascal>TCL

Category Language