home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / p / plbin.zip / pl / library / quintus.pl < prev    next >
Text File  |  1993-02-03  |  3KB  |  146 lines

  1. /*  quintus.pl,v 1.5 1993/02/03 09:13:14 jan Exp
  2.  
  3.     Copyright (c) 1990 Jan Wielemaker. All rights reserved.
  4.     jan@swi.psy.uva.nl
  5.  
  6.     Purpose: Quintus compatibility predicates
  7. */
  8.  
  9. :- module(quintus,
  10.     [ unix/1
  11. %    , file_exists/1
  12.     , call/2
  13.     , call/3
  14.  
  15.     , abs/2
  16.     , sin/2
  17.     , cos/2
  18.     , tan/2
  19.  
  20.     , (mode)/1
  21.     , (public)/1
  22.     , (meta_predicate)/1
  23.     , no_style_check/1
  24.     , retractall/1
  25.     ]).
  26.  
  27.         /********************************
  28.         *      SYSTEM INTERACTION       *
  29.         *********************************/
  30.  
  31. %    unix(+Action)
  32. %    interface to  Unix.   Currently  only  `system( Command)'  is
  33. %    available as `Action'.
  34.  
  35. unix(system(Command)) :-
  36.     shell(Command).
  37. unix(access(File, 0)) :-
  38.     access_file(File, read).
  39.  
  40. %    file_exists( +File )
  41. %    Succeeds if `File' exists as a file or directory in the Unix file
  42. %    system.
  43.  
  44. file_exists( File ) :-
  45.     exists_file( File ).
  46.  
  47.         /********************************
  48.         *        META PREDICATES        *
  49.         *********************************/
  50.  
  51. :- module_transparent
  52.     call/2,
  53.     call/3,
  54.     retractall/1.
  55.  
  56. %    call( +Pred,+Argument,... )
  57. %    call `Pred', appending the additional arguments to the goal
  58.  
  59. call(Pred, A0) :-
  60.     apply(Pred, [A0]).
  61. call( Pred,A0,A1 ) :-
  62.     apply(Pred, [A0,A1]).
  63.  
  64.  
  65. %    The quintus definition of retractall/1 retracts on the basis of
  66. %    *head* rather then *clause* declarations.
  67.  
  68. retractall(Head) :-
  69.     retract(Head),
  70.     fail.
  71. retractall(Head) :-
  72.     retract((Head :- _)),
  73.     fail.
  74. retractall(_).
  75.  
  76.  
  77.         /********************************
  78.         *          ARITHMETIC           *
  79.         *********************************/
  80.  
  81. %    abs( +Number,-Absolute )
  82. %    Unify `Absolute' with the absolute value of `Number'.
  83.  
  84. abs( Number,Absolute ) :-
  85.     Absolute is abs(Number).
  86.  
  87. %    Math library predicates
  88.  
  89. sin(A, V) :- V is sin(A).
  90. cos(A, V) :- V is cos(A).
  91. tan(A, V) :- V is tan(A).
  92.  
  93.  
  94.         /********************************
  95.         *          STYLE CHECK          *
  96.         *********************************/
  97.  
  98. q_style_option(single_var, singleton) :- !.
  99. q_style_option(Option, Option).
  100.  
  101. no_style_check(QOption) :-
  102.     q_style_option(QOption, SWIOption),
  103.     style_check(-SWIOption).
  104.  
  105.         /********************************
  106.         *            OPERATORS          *
  107.         *********************************/
  108.  
  109. :- op(0, fy, not).
  110.  
  111.         /********************************
  112.         *         DIRECTIVES            *
  113.         *********************************/
  114.  
  115. % :- op(1150, fx, [(mode), (public)]).
  116.  
  117. mode(_).
  118. public(_).
  119.  
  120.         /********************************
  121.         *            MODULES            *
  122.         *********************************/
  123.  
  124. :- op(1150, fx, (meta_predicate)).
  125.  
  126. :- module_transparent
  127.     (meta_predicate)/1,
  128.     (meta_predicate1)/1.
  129.  
  130. meta_predicate((Head, More)) :- !, 
  131.     meta_predicate1(Head), 
  132.     meta_predicate(More).
  133. meta_predicate(Head) :-
  134.     meta_predicate1(Head).
  135.  
  136. meta_predicate1(Head) :-
  137.     Head =.. [Name|Arguments], 
  138.     member(Arg, Arguments), 
  139.     module_expansion_argument(Arg), !, 
  140.     functor(Head, Name, Arity), 
  141.     module_transparent(Name/Arity).
  142. meta_predicate1(_).        % just a mode declaration
  143.  
  144. module_expansion_argument(:).
  145. module_expansion_argument(N) :- integer(N).
  146.