Longest increasing subsequence: Difference between revisions

Content added Content deleted
Line 830: Line 830:


<lang prolog>lis(In, Out) :-
<lang prolog>lis(In, Out) :-
% we asl Prolog to find the longest sequence
% we ask Prolog to find the longest sequence
aggregate(max(N,Is), (one_is(In, [], Is), length(Is, N)), max(_, Res)),
aggregate(max(N,Is), (one_is(In, [], Is), length(Is, N)), max(_, Res)),
reverse(Res, Out).
reverse(Res, Out).