home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / nvdc87 / lcv1n1 / mean-p.pro < prev    next >
Text File  |  1987-08-11  |  669b  |  25 lines

  1. /* Listing 2 - Turbo Prolog module to call C to find the mean, 
  2.                which is passed back in a functor. */
  3.  
  4. domains
  5.    ilist=real*
  6.    ifunc=f(real)
  7.  
  8. global predicates
  9.    cpinit language c         /* declare Turbo C initialization */
  10.                              /* module, cpinit                 */
  11.    mean(ilist,ifunc) - (i,o) (o,i) language c 
  12.                              /* declare Turbo C module, mean.  */
  13. predicates
  14.    process(ilist)
  15.  
  16. goal
  17.    cpinit,                
  18.    process([1.0,5.0,10.0,14.0]).
  19.    
  20. clauses
  21.    process(List):-
  22.       mean(List,Ans),    /* Call Turbo C module to calculate mean */
  23.       write(Ans),nl.
  24.       
  25.