Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
#######
#
# E-scripts on Pascal.
#
# Note 1: use the eev command (defined in eev.el) and the
# ee alias (in my .zshrc) to execute parts of this file.
# Executing this file as a whole makes no sense.
# An introduction to eev can be found here:
#
#   (find-eev-quick-intro)
#   http://angg.twu.net/eev-intros/find-eev-quick-intro.html
#
# Note 2: be VERY careful and make sure you understand what
# you're doing.
#
# Note 3: If you use a shell other than zsh things like |&
# and the for loops may not work.
#
# Note 4: I always run as root.
#
# Note 5: some parts are too old and don't work anymore. Some
# never worked.
#
# Note 6: the definitions for the find-xxxfile commands are on my
# .emacs.
#
# Note 7: if you see a strange command check my .zshrc -- it may
# be defined there as a function or an alias.
#
# Note 8: the sections without dates are always older than the
# sections with dates.
#
# This file is at <http://angg.twu.net/e/pascal.e>
#           or at <http://angg.twu.net/e/pascal.e.html>.
#        See also <http://angg.twu.net/emacs.html>,
#                 <http://angg.twu.net/.emacs[.html]>,
#                 <http://angg.twu.net/.zshrc[.html]>,
#                 <http://angg.twu.net/escripts.html>,
#             and <http://angg.twu.net/>.
#
#######





# (find-fline "/usr/share/doc/gcc-4.1-base/pascal/examples/")
# (find-fline "/usr/share/doc/gcc-4.1-base/pascal/docdemos/")

# (find-status   "gpc-4.1-doc")
# (find-vldifile "gpc-4.1-doc.list")
# (find-udfile   "gpc-4.1-doc/")
# (find-status   "gpc-4.1")
# (find-vldifile "gpc-4.1.list")
# (find-udfile   "gpc-4.1/")
# (find-status   "gpc-doc")
# (find-vldifile "gpc-doc.list")
# (find-udfile   "gpc-doc/")
# (find-status   "gpc")
# (find-vldifile "gpc.list")
# (find-udfile   "gpc/")

# (find-node "(gpc-4.1)")
# (find-node "(gpcs-4.1)")

# (find-node "(gpc)Pointer Arithmetics")
# (find-node "(gpc)Data Types")
# (find-node "(gpc)Procedural Types")
# (find-node "(gpc)Run Time System")
# (find-node "(gpc)GPC Units")

# (find-node "(gpc)Programming")
# (find-node "(gpc)The Function")
# (find-node "(gpc)The Procedure")
# (find-node "(gpc)WriteLn")

     function FUNCTION_IDENTIFIER (PARAMETER_LIST): RESULT_TYPE;
     DECLARATION_PART
     begin
       STATEMENT_PART
     end;


#*
cat > /tmp/foo.pas <<'%%%'
program teste;
function m(a: integer; b: integer): integer;
  begin WriteLn("  ", a, "*", b, " -> ", a*b); return(a*b); end;
function s(a: integer; b: integer): integer;
  begin WriteLn("  ", a, "+", b, " -> ", a+b); return(a+b); end;
function P1(a: integer): boolean;
  begin WriteLn("  ", a, "*", a, " < 10 -> ", a*a<10); return(a*a<10); end;
function P2(a: integer): boolean;
  begin WriteLn("  ", a, "=4 -> ", a=4); return a=4; end;
function P3(a: integer): boolean;
  begin WriteLn("  ", a, ">=9 -> ", a>=9); return a>=9; end;
procedure testaordem;
  begin WriteLn("2*3 + 4*5:");
        WriteLn(" -> ", s(m(2, 3), m(4, 5)));
        WriteLn;
  end;
procedure f123(function f(a: integer; b: integer): integer);
  begin WriteLn("f(f(1,2), f(3,4)):");
        WriteLn(" -> ", f(f(1, 2), f(3, 4)));
        WriteLn;
  end;
procedure existe_a_em_A_tal_que(function P(a: integer): boolean);
  begin WriteLn("Existe a em {1, 2, 4} tal que P:");
        WriteLn("-> P(1) or P(2) or P(4)");
        WriteLn(" -> ", P(1) or P(2) or P(4));
        WriteLn;
  end;

begin
  testaordem;
  f123(s);
  f123(m);
  existe_a_em_A_tal_que(P1);
  existe_a_em_A_tal_que(P2);
  existe_a_em_A_tal_que(P3);
end.

(* Output:

2*3 + 4*5:
 ->   4*5 -> 20
  2*3 -> 6
  6+20 -> 26
26

f(f(1,2), f(3,4)):
 ->   3+4 -> 7
  1+2 -> 3
  3+7 -> 10
10

f(f(1,2), f(3,4)):
 ->   3*4 -> 12
  1*2 -> 2
  2*12 -> 24
24

Existe a em {1, 2, 4} tal que P:
-> P(1) or P(2) or P(4)
  1*1 < 10 -> True
 -> True

Existe a em {1, 2, 4} tal que P:
-> P(1) or P(2) or P(4)
  1=4 -> False
  2=4 -> False
  4=4 -> True
 -> True

Existe a em {1, 2, 4} tal que P:
-> P(1) or P(2) or P(4)
  1>=9 -> False
  2>=9 -> False
  4>=9 -> False
 -> False

*)
%%%

cd /tmp/
gpc foo.pas && a.out

#*

# (find-sh "cd /tmp/ && gpc foo.pas && a.out")


int P1(int a) { printf("  %d*%d < 10 -> %d\n", a, a, a*a<10); return a*a<10; }
int P2(int a) { printf("  %d==4 -> %d\n", a, a==4); return a==4; }
int P3(int a) { printf("  %d>=9 -> %d\n", a, a>=9); return a>=9; }







%d*%d -> %d\n"


#include <stdio.h>
int m(int a, int b) { printf("  %d*%d -> %d\n", a, b, a*b); return a*b; }
int s(int a, int b) { printf("  %d+%d -> %d\n", a, b, a+b); return a+b; }
int P1(int a) { printf("  %d*%d < 10 -> %d\n", a, a, a*a<10); return a*a<10; }
int P2(int a) { printf("  %d==4 -> %d\n", a, a==4); return a==4; }
int P3(int a) { printf("  %d>=9 -> %d\n", a, a>=9); return a>=9; }
void testaordem(void) {
  printf("2*3 + 4*5: \n");
  printf(" -> %d\n\n", s(m(2, 3), m(4, 5)));
}
void f123(int(*f)()) {
  printf("f(f(1,2), f(3,4)):\n");
  printf(" -> %d\n\n", f(f(1, 2), f(3, 4))); 
}
void existe_a_em_A_tal_que(int(*P)()) {
  printf("Existe a em {1, 2, 4} tal que P:\n");
  printf("-> P(1) || P(2) || P(4)\n");
  printf(" -> %d\n\n", P(1) || P(2) || P(4)); 
}

main() {
  testaordem();
  f123(s);
  f123(m);
  existe_a_em_A_tal_que(P1);
  existe_a_em_A_tal_que(P2);
  existe_a_em_A_tal_que(P3);
}





#####
#
# factorial
# 2011apr20
#
#####

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cat > /tmp/foo.pas <<'%%%'
program teste;
function fact(n: integer): integer;
  if n <= 0 then return 1;
  return n * fact(n - 1);
end;
begin
  WriteLn(fact(4));
end.
(* ...
*)
%%%
cd /tmp/
gpc foo.pas && a.out





Why Pascal is Not My Favorite Programming Language
by Brian W. Kernighan
https://www.lysator.liu.se/c/bwk-on-pascal.html

http://www.pbm.com/~lindahl/real.programmers.html Real Programmers Don't Use Pascal







See: lua-l, 2012nov06 (Luciano de Souza / Romulo AB)






#  Local Variables:
#  coding:               utf-8-unix
#  End: