home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / nvdc87 / lcv1n1 / variance.pro < prev   
Text File  |  1987-08-11  |  1KB  |  38 lines

  1. /* Listing 4 - Turbo Prolog main module to call Turbo C to calculate 
  2.                the variance. The variance is passed back to Turbo 
  3.                Prolog as a real */
  4.  
  5. domains
  6.    ilist=real*
  7.    ifunc=real
  8.    
  9. database
  10.    answer(real)
  11.  
  12. global predicates
  13.    cpinit language c         /* declare Turbo C initialization    */
  14.                              /* module, cpinit  */
  15.    variance(ilist,ifunc) - (i,o) language c 
  16.                              /* declare Turbo C module, variance  */
  17.     
  18. predicates
  19.    main
  20.    process(ilist)
  21.  
  22. goal
  23.    cpinit,     /* cpinit must be invoked before we call the */
  24.    main.       /* TC function. */
  25.                 
  26.                          
  27. clauses
  28.    main:-
  29.       List = [1.0,5.0,10.0,14.0],
  30.       process(List).
  31.  
  32.    process(List):-
  33.       variance(List,Answer),   /* Pass the list to variance */
  34.       Answer > 10,             /* Then, the condition succeeds */
  35.       write(Answer).
  36.    process(_):-             /* Else, say it doesn't */
  37.       write("Condition fails.").
  38.