Version 12 of Pascal

Updated 2006-02-01 23:01:55

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

Pascal is a procedural language, similar to C. Both of these are descendants from Algol.

Pascal descandents include: Delphi, Modula 2, Modula 3 [L1 ], Oberon. 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, given one 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 :)


Category Language