home *** CD-ROM | disk | FTP | other *** search
Prolog Source | 1987-08-11 | 1.0 KB | 38 lines |
- /* Listing 4 - Turbo Prolog main module to call Turbo C to calculate
- the variance. The variance is passed back to Turbo
- Prolog as a real */
-
- domains
- ilist=real*
- ifunc=real
-
- database
- answer(real)
-
- global predicates
- cpinit language c /* declare Turbo C initialization */
- /* module, cpinit */
- variance(ilist,ifunc) - (i,o) language c
- /* declare Turbo C module, variance */
-
- predicates
- main
- process(ilist)
-
- goal
- cpinit, /* cpinit must be invoked before we call the */
- main. /* TC function. */
-
-
- clauses
- main:-
- List = [1.0,5.0,10.0,14.0],
- process(List).
-
- process(List):-
- variance(List,Answer), /* Pass the list to variance */
- Answer > 10, /* Then, the condition succeeds */
- write(Answer).
- process(_):- /* Else, say it doesn't */
- write("Condition fails.").
-