]> Repositorios git - scryer-prolog.git/commitdiff
weighted_maximum/3 now works
authorMarkus Triska <[email protected]>
Wed, 16 Oct 2019 17:17:03 +0000 (19:17 +0200)
committerMarkus Triska <[email protected]>
Wed, 16 Oct 2019 17:18:38 +0000 (19:18 +0200)
src/prolog/lib/clpb.pl

index 0ddfc9860fc7a82ba6256df624f60219410f6478..d35b488c1d4d9a5b6624ccab8ddad7b93ad1d27c 100644 (file)
@@ -34,7 +34,7 @@
 :- use_module(library(lists)).
 :- use_module(library(non_iso)).
 :- use_module(library(dcgs)).
-%:- use_module(library(types)).
+:- use_module(library(error), []).
 
 :- attribute
         clpb/1,
@@ -77,8 +77,8 @@ must_be(list(What), Where, Term) :- !,
 must_be(ground, _, Term) :- !,
         functor(Term, _, _).
 
-must_be(Type, Goal-Arg, Term) :-
-        must_be(Term, Type, Goal, Arg).
+must_be(Type, _, Term) :-
+        error:must_be(Type, Term).
 
 clpz_list(Nil, _) :- Nil == [].
 clpz_list(Ls, Where) :-
@@ -87,7 +87,6 @@ clpz_list(Ls, Where) :-
     ;   Ls = [_|Rest],
         clpz_list(Rest, Where)
     ).
-    
 
 
 instantiation_error(Term) :- instantiation_error(Term, unknown(Term)-1).
@@ -139,7 +138,10 @@ partition(Pred, Ls0, As, Bs) :-
         include(Pred, Ls0, As),
         exclude(Pred, Ls0, Bs).
 
-sum_list(Ls, S) :- sumlist(Ls, S).
+sum_list(Ls, S) :-
+        foldl(sum_, Ls, 0, S).
+
+sum_(L, S0, S) :- S is S0 + L.
 
 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   Pairs.