Merge pull request #206 from triska/master
weighted_maximum/3 now works
This commit is contained in:
@@ -34,7 +34,7 @@
|
|||||||
:- use_module(library(lists)).
|
:- use_module(library(lists)).
|
||||||
:- use_module(library(non_iso)).
|
:- use_module(library(non_iso)).
|
||||||
:- use_module(library(dcgs)).
|
:- use_module(library(dcgs)).
|
||||||
%:- use_module(library(types)).
|
:- use_module(library(error), []).
|
||||||
|
|
||||||
:- attribute
|
:- attribute
|
||||||
clpb/1,
|
clpb/1,
|
||||||
@@ -77,8 +77,8 @@ must_be(list(What), Where, Term) :- !,
|
|||||||
must_be(ground, _, Term) :- !,
|
must_be(ground, _, Term) :- !,
|
||||||
functor(Term, _, _).
|
functor(Term, _, _).
|
||||||
|
|
||||||
must_be(Type, Goal-Arg, Term) :-
|
must_be(Type, _, Term) :-
|
||||||
must_be(Term, Type, Goal, Arg).
|
error:must_be(Type, Term).
|
||||||
|
|
||||||
clpz_list(Nil, _) :- Nil == [].
|
clpz_list(Nil, _) :- Nil == [].
|
||||||
clpz_list(Ls, Where) :-
|
clpz_list(Ls, Where) :-
|
||||||
@@ -89,7 +89,6 @@ clpz_list(Ls, Where) :-
|
|||||||
).
|
).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
instantiation_error(Term) :- instantiation_error(Term, unknown(Term)-1).
|
instantiation_error(Term) :- instantiation_error(Term, unknown(Term)-1).
|
||||||
|
|
||||||
instantiation_error(_, Goal-Arg) :-
|
instantiation_error(_, Goal-Arg) :-
|
||||||
@@ -139,7 +138,10 @@ partition(Pred, Ls0, As, Bs) :-
|
|||||||
include(Pred, Ls0, As),
|
include(Pred, Ls0, As),
|
||||||
exclude(Pred, Ls0, Bs).
|
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.
|
Pairs.
|
||||||
|
|||||||
@@ -33,6 +33,10 @@ must_be(Type, Term) :-
|
|||||||
must_be_(Type, _) :-
|
must_be_(Type, _) :-
|
||||||
var(Type),
|
var(Type),
|
||||||
instantiation_error(Type).
|
instantiation_error(Type).
|
||||||
|
must_be_(var, Term) :-
|
||||||
|
( var(Term) -> true
|
||||||
|
; throw(error(uninstantiation_error, _))
|
||||||
|
).
|
||||||
must_be_(integer, Term) :- check_(integer, integer, Term).
|
must_be_(integer, Term) :- check_(integer, integer, Term).
|
||||||
must_be_(atom, Term) :- check_(atom, atom, Term).
|
must_be_(atom, Term) :- check_(atom, atom, Term).
|
||||||
must_be_(list, Term) :- check_(ilist, list, Term).
|
must_be_(list, Term) :- check_(ilist, list, Term).
|
||||||
@@ -52,6 +56,7 @@ type(type).
|
|||||||
type(integer).
|
type(integer).
|
||||||
type(atom).
|
type(atom).
|
||||||
type(list).
|
type(list).
|
||||||
|
type(var).
|
||||||
|
|
||||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
can_be(Type, Term)
|
can_be(Type, Term)
|
||||||
|
|||||||
Reference in New Issue
Block a user