From e6782ebbcd454f0da397025bf99e1868ad4c4a25 Mon Sep 17 00:00:00 2001 From: tocariimaa Date: Mon, 17 Feb 2025 00:33:59 -0300 Subject: [PATCH] articles/pascal.md: update --- articles/pascal.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/articles/pascal.md b/articles/pascal.md index 121b14c..f4db1a5 100644 --- a/articles/pascal.md +++ b/articles/pascal.md @@ -9,7 +9,7 @@ In its "vanilla" form, Pascal is not any more complex than C, aside from having such as range types, nested procedures, sets, builtin tagged unions, etc. Pascal has an ISO standard: ISO 7185. Since the Pascal described in said standard is quite useless for practical programming, -most compilers are for an extended superset of Pascal. +most compilers are for an extended superset of the Pascal described in that standard. ## Compilers - [FPC](https://www.freepascal.org/) (Free Pascal Compiler): currently the most popular Pascal compiler with wide support @@ -61,14 +61,10 @@ fpc hellopascal.pas ### Factorial ```pascal -{ - Calculate a factorial on multiple languages: Pascal version - Compile with: fpc -O3 -S2 fact.pas -} -program Factorials; +program Factorial; { qword = 64 bit unsigned type } -function Factorial(n: qword): qword; +function factorial(n: qword): qword; begin Result := 1; while n > 0 do @@ -76,7 +72,7 @@ begin { The usage of C-like arithmetic assignment operators is possible with -Sc: } { Result *= n; } Result := Result * n; - Dec(n); { equivalent to C's `--` operator } + dec(n); { equivalent to C's `--` operator } end; end; @@ -86,11 +82,16 @@ var begin for n in values do begin - WriteLn('Factorial of ', n, ' = ', Factorial(n)); + writeLn('Factorial of ', n, ' = ', factorial(n)); end; end. ``` +Compiling: +``` +fpc -O3 -S2 fact.pas +``` + ## Resources - [Free Pascal Wiki](https://wiki.freepascal.org/Main_Page) - [Basic Pascal Tutorial](https://wiki.freepascal.org/Basic_Pascal_Tutorial)