Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % count(Count, First, Last, Index):
- %
- % Count the number of values in an index, providing the first and last
- % indexes.
- %
- :- pred count(int::out, int::out, int::out, T::in) is det.
- count(C, F, L, T) :-
- ( A = func(I, U@{Count, First0, Last0}) = {Count + 1, First, Last} :-
- ( U = {0, 0, 0} ->
- First = I, Last = I
- ;
- First = (First0 < I -> First0 ; I),
- Last = (Last0 > I -> Last0 ; I)
- )
- ),
- (P = pred(I) :- index(I, T)),
- aggregate(P, A, {0, 0, 0}, {C, F, L}).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement