1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
%X is Y + 1 %nie wolno: Z is Z + 1 rosnacy(L) :- [H|T] = L, rosnacy(T), [H2|T2] = T, H < H2. rosnacy([X]). maxlist(L, M) :- [H|T] = L, maxlist(T, M2), H > M2, M is H. maxlist(L, M) :- [H|T] = L, maxlist(T, M2), H =< M2, M is M2. maxlist([L], M) :- M is L. split(L, P, NP) :- [H|T] = L, mod(H, 2) =:= 0, split(T, P2, NP2), P = [H|P2], NP = NP2. split(L, P, NP) :- [H|T] = L, mod(H, 2) =\= 0, split(T, P2, NP2), NP = [H|NP2], P = P2. split([], [], []). sumlist(L, S) :- [H|T] = L, sumlist(T, S2), S is H + S2. sumlist([], 0). ilelist(L, N) :- [H|T] = L, ilelist(T, N2), N is 1 + N2. ilelist([], 0). srednia(L, S) :- sumlist(L, S2), ilelist(L, N2), N2 =\= 0, S is S2 / N2. arytmetyczny(L) :- [H|T] = L, [H2|T2] = T, [H3|T3] = T2, H2 - H =:= H3 - H2, arytmetyczny(T). arytmetyczny([]).