Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %returns true iff all bids in [Bids] results in all Items being sold
- %func2/2(+[Items], +[Bids])
- func2([item(T,N)|Is],Bs) :- Is == [], func3(T,Bs,Count), Count == N.
- func2([item(T,N)|Is],Bs) :- func2(Is, Bs), func3(T,Bs,Count), Count == N.
- %func3/3(+Type, +[Bids], ?Count).
- func3(_,[],0).
- func3(Type,[bid(_, Items, _)|Bs],Count) :- func3(Type, Bs, C), countItem(Items, Type, C1), Count is C + C1.
- %counts the sum of bids for a particular item
- %countItem/3(+[Items], +Type, ?NumberOfItem).
- countItem([],_,0).
- countItem([item(Type,N)|Xs], T, Count) :- Type == T, countItem(Xs, T, C), Count is C + N.
- countItem([item(Type,_)|Xs], T, Count) :- Type \= T, countItem(Xs, T, Count).
Add Comment
Please, Sign In to add comment