Unnamed
public text v1 · immutablecount([], [], 0).
count([_|IT], IT, 1).
count([IH|IT], OL, N1) :- IT=[IH|_], count(IT,OL,N), N1 is N+1.
headisnot([],_).
headisnot([[_,H]|_],E) :- H \= E.
rle([], []).
rle([IH|IT], [[N,IH]|OT]) :- count([IH|IT],NI,N), rle(NI,OT), headisnot(OT, IH).
% rle([a,a,a],[[3,a]]).
% rle([a,a],[[2,a]]).
% rle([a,a],[[1,a],[1,a]]).
% rle(What,[[2,a],[2,b]]).
% rle([a,a,a,a,b,b],What).