home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lifeos2.zip / LIFE-1.02 / TESTS / REFOUT / LISTING1.REF < prev    next >
Text File  |  1996-06-04  |  5KB  |  201 lines

  1.  
  2. *** Yes
  3. > > > |    |    |    |    |    |    |    |    |    |    |    |    |    
  4. % non_strict(non_strict)?
  5. % 'non_strict' is a built-in predicate.
  6.  
  7. % non_strict(dynamic)?
  8. % 'dynamic' is a built-in predicate.
  9.  
  10. % non_strict(delay_check)?
  11. % 'delay_check' is a built-in predicate.
  12.  
  13. % 'assert' is a built-in predicate.
  14.  
  15. % 'asserta' is a built-in predicate.
  16.  
  17. % 'retract' is a built-in predicate.
  18.  
  19. % 'clause' is a built-in predicate.
  20.  
  21. non_strict(load)?
  22. _A: load :-
  23.         _B = current_module,
  24.         _C = features(_A,"built_ins"),
  25.         (loading,
  26.         !,
  27.         load_2(_C,_A) ; loading <<- true,
  28.         top_load <<- get_choice,
  29.         load_2(_C,_A),
  30.         !,
  31.         loading <<- false ; open_out("stdout",@),
  32.         open_in("stdin",@),
  33.         set_module(_B),
  34.         loading <<- false,
  35.         fail).
  36.  
  37. % 'load_2' is undefined.
  38.  
  39. % 'load_3' is undefined.
  40.  
  41. % 'load_path' is undefined.
  42.  
  43. life_ext -> {".lf";"";(load_suffixes | is_function(` load_suffixes));".life"}.
  44.  
  45. non_strict(listing)?
  46. _A: listing :-
  47.         listing_2(features(_A,"built_ins"),_A).
  48.  
  49. % 'listing_2' is undefined.
  50.  
  51. % 'listing_3' is undefined.
  52.  
  53. % 'listing_4' is undefined.
  54.  
  55. % 'listing_4a' is undefined.
  56.  
  57. % 'listing_5' is undefined.
  58.  
  59. % 'listing_6' is undefined.
  60.  
  61. non_strict(op)?
  62. op(_A,_B,_C,functor => _C,kind => _B,precedence => _A) :-
  63.         trace(_D,_E),
  64.         (op_2(_A,_B,_C),
  65.         trace(_D,_E) ; trace(_D,_E),
  66.         fail).
  67.  
  68. non_strict(op)?
  69. op(_A,_B,_C,functor => _C,kind => _B,precedence => _A) :-
  70.         trace(_D,_E),
  71.         (op_2(_A,_B,_C),
  72.         trace(_D,_E) ; trace(_D,_E),
  73.         fail).
  74.  
  75. % 'op_2' is undefined.
  76.  
  77. % 'op_3' is undefined.
  78.  
  79. call_handler(_A) :-
  80.         is_sort(_A),
  81.         !,
  82.         write_err("*** Error: the sort '"),
  83.         writeq_err(_A),
  84.         write_err("' occurs where a predicate or function is expected."),
  85.         nl_err,
  86.         abort.
  87. call_handler(_A) :-
  88.         !,
  89.         write_err("*** Error: '"),
  90.         writeq_err(_A),
  91.         write_err("' is not a predicate or a function."),
  92.         nl_err,
  93.         abort.
  94.  
  95. nl :-
  96.         write("
  97. ").
  98.  
  99. \+ _A :-
  100.         _A,
  101.         !,
  102.         fail.
  103. \+ :-
  104.         succeed.
  105.  
  106. non_strict(bagof)?
  107. bagof(_A,
  108.       _B) -> _C | _D <<- [],(evalin(_B), _D <<- [evalin(_A)|copy_pointer(_D)], fail ; _C <- copy_term(_D)).
  109.  
  110. reduce(_A,_B,[_C|_D]) -> apply(_C,reduce(_A,_B,_D),functor => _A).
  111. reduce(@,_A,[]) -> _A.
  112.  
  113. map(@,[]) -> [].
  114. map(_A,[_B|_C]) -> [apply(_B,functor => _A)|map(_A,_C)].
  115.  
  116. maprel(_A,[_B|_C]) :-
  117.         !,
  118.         root_sort(_A) & @(_B),
  119.         maprel(_A,_C).
  120. maprel(@,[]) :-
  121.         succeed.
  122.  
  123. append([],_A: list) -> _A.
  124. append([_A|_B],_C: list) -> [_A|append(_B,_C)].
  125.  
  126. length([]) -> 0.
  127. length([@|_A]) -> 1 + length(_A).
  128.  
  129. [] <| list.
  130.  
  131. cons <| list.
  132.  
  133. % 'car' is undefined.
  134.  
  135. % 'cdr' is undefined.
  136.  
  137. % 'repeat' is a built-in predicate.
  138.  
  139. % 'where' is undefined.
  140.  
  141. % 'and' is a built-in function.
  142.  
  143. % 'or' is a built-in function.
  144.  
  145. % 'not' is a built-in function.
  146.  
  147. % 'xor' is a built-in function.
  148.  
  149. % 'int2str' is a built-in function.
  150.  
  151. % 'num' is undefined.
  152.  
  153. str(_A) -> cond(is_value(_A),strval(_A),psi2str(_A)).
  154.  
  155. strval(_A: string) -> _A.
  156. strval(_A: int) -> int2str(_A).
  157.  
  158. "" $== "" -> true.
  159. _A: string $== _B: string -> asc(_A) =:= asc(_B) and lenstreq(substr(_A,
  160.                                                                      2,
  161.                                                                      _C: strlen(_A)),
  162.                                                               substr(_B,
  163.                                                                      2,
  164.                                                                      _D: strlen(_B)),
  165.                                                               _C,
  166.                                                               _D).
  167.  
  168. _A: string $\== _B: string -> not _A $== _B.
  169.  
  170. _A: string $< _B: string -> _A $=< _B and not _A $== _B.
  171.  
  172. "" $=< string -> true.
  173. string $=< "" -> false.
  174. _A: string $=< _B: string -> _C: asc(_A) < _D: asc(_B) or _C =:= _D and lenstrle(substr(_A,
  175.                                                                                         2,
  176.                                                                                         _E: strlen(_A)),
  177.                                                                                  substr(_B,
  178.                                                                                         2,
  179.                                                                                         _F: strlen(_B)),
  180.                                                                                  _E,
  181.                                                                                  _F).
  182.  
  183. _A: string $> _B: string -> not _A $=< _B.
  184.  
  185. _A: string $>= _B: string -> not _A $=< _B or _A $== _B.
  186.  
  187. % 'set' is undefined.
  188.  
  189. % 'setq' is a built-in predicate.
  190.  
  191. _A ^ _B: int -> cond(_B < 0,1 / pwr(_A,- _B),pwr(_A,_B)).
  192.  
  193. % 'pwr' is undefined.
  194.  
  195. max(_A,_B) -> cond(_A > _B,_A,_B).
  196.  
  197. min(_A,_B) -> cond(_A > _B,_B,_A).
  198.  
  199. *** Yes
  200.