Version 9 of Pascal

Updated 2004-02-20 14:16:19

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

Pascal is a procedural language, similar to C.

Descendents include: Delphi, Modula 2, 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


Category Language


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...

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