convert.pl

loading
details
attribute value
description
owner Johannes Waldmann
uploaded 2017-08-17 03:45:17.0
disk size 526 Bytes
downloadable true
type
attribute value
name no_type
processor id 1
description this is the default benchmark type for rejected benchmarks and benchmarks that are not associated with a type.
owning community none
loading contents
% Adapted from LP/SGST06/convert.pl
% terminating

%query: convert(i,i,o).
convert([],_,Z) :- !, eq(Z,0).
convert(X,Y,Z) :- head(X,0), !, tail(X,T), convert(T,Y,U), times(U,Y,Z).
convert(X,Y,Z) :- head(X,H), p(H,P), tail(X,T), convert([P|T],Y,U), p(Z,U), !.

times(0,Y,Z) :- !, eq(Z,0).
times(X,Y,Z) :- p(X,P), times(P,Y,U), plus(Y,U,Z).

plus(0,Y,Z) :- !, eq(Y,Z).
plus(X,Y,Z) :- p(X,P), plus(P,Y,U), p(Z,U), !.

head([],_).
head([H|_],H).

tail([],[]).
tail([_|Xs],Xs).

p(s(X),X).
p(0,0).

eq(X,X).
popout

content may be truncated. 'popout' for larger text window.

actions get anonymous link download benchmark