%
% Important note: the following class example is provided "as
% is", for reference purposes, and without any claims of correctness.
%

% 10.2

% 1
sublist(S, L) :- myprefix(S, L).
sublist(S, [_|T]) :- sublist(S, T).
myprefix([], _).
myprefix([H|T1], [H|T2]) :- myprefix(T1, T2).

% 2
collatz(1, [1]).
collatz(N, L) :-
	0 is N mod 2,
	Np is N // 2,
	collatz(Np, Lp), L = [N|Lp].
collatz(N, L) :-
	Np is (3 * N + 1),
	collatz(Np, Lp),
	L = [N|Lp].
% 6, 3, 10, 5, 16, 8, 4, 2, 1


% 10.3, see mysmc-mod.pl