home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.pascal
- Path: sparky!uunet!math.fu-berlin.de!zrz.tu-berlin.de!cs.tu-berlin.de!veit
- From: veit@opal.cs.tu-berlin.de (Veit Zimmermann)
- Subject: Re: Functions and Procedures as Parameters
- Message-ID: <1992Jul21.203545.1907@cs.tu-berlin.de>
- Sender: news@cs.tu-berlin.de
- Organization: Techn. University of Berlin, Germany
- References: <BrpxpG.351@ux1.cso.uiuc.edu>
- Distribution: fb20
- Date: Tue, 21 Jul 1992 20:35:45 GMT
- Lines: 33
-
- husak@ux1.cso.uiuc.edu (Stephen R. Husak ) writes:
-
- >I've been trying to implement the following in TP5.5... Could someone
- >either clue me in or tell me if it is possible.
- >
- >I want to pass a function into another function:
- >
- >eg -- function First(a,b: real;
- > function test(x:integer):integer);
- >
- > { rest of function follows }
- [stuff deleted]
- You're lucky
- I did this two days ago. It goes like this:
- First you must declare a FunctionType e.g. :
- Type TestFunc = FUNCTION (x : INTEGER) : INTEGER;
-
- Now you are able to do this :
- FUNCTION First (a, b : REAL;
- test : TestFunc) : INTEGER;
- BEGIN
- first := test (TRUNC (a*b));
- END;
-
- Calling First goes simply like this :
- First (x, y, TrueTester);
-
- with TrueTester (x : INTEGER) : INTEGER;
-
- Hope this helps
-
- CIAO
- veit [zimzim@marie.physik.tu-berlin.de]
-