Advertisement
logicmoo

Byrd - Saveit

Aug 23rd, 2015
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.46 KB | None | 0 0
  1. agg_all(min(X), Goal, Min) :-
  2.   State = state(X),  % X looks lovely here - really its just a hack so we don't reserve a new slot on the stack like using _ would. we could have easily written:  State = state(Goal),
  3.    (  call(Goal),
  4.      (
  5.       % savit
  6.       (nb_setarg(1, State, X),fail)
  7.   ;
  8.      
  9.      % 2nd - Nth
  10.      ( arg(1, State, M0),
  11.       M is min(M0,X),
  12.       nb_setarg(1, State, M),
  13.       fail))
  14.    ;  arg(1, State, Min),
  15.       nonvar(Min)
  16.    ).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement