Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bin(X,L1) :- X =:= 0, L1=[],!.
- bin(X,L1) :- X1 is div(X,2),
- X2 is mod(X,2),
- bin(X1,T2), L1=[X2|T2].
- odw(L1,L2) :- L1=[],L2=[].
- odw(L1,L2) :- L1=[H|T],
- append(T2,[H],L2),
- odw(T,T2),!.
- bintru(X,L1) :- bin(X,L2), odw(L2,L1).
- zera(X,L2) :- X=:=0, L2=[].
- zera(X,L2) :- X1 is X-1, L2=[0|T], zera(X1,T),!.
- dopisywanie(L1,L2,L3) :- length(L1,D1) , length(L2,D2), D1>D2,
- D3 is D1-D2, dop(L2,D3,L3).
- dopisywanie(L1,L2,L3) :- length(L1,D1) , length(L2,D2), D1=<D2,
- D3 is D2-D1, dop(L1,D3,L3).
- porownanie(L1,L2,I) :- I is 0, L1=[],L2=[].
- porownanie(L1,L2,I) :- L1=[H1|T1],L2=[H2|T2], porownanie(T1,T2,I1),
- H1=:=H2,
- I is I1+0.
- porownanie(L1,L2,I) :- L1=[H1|T1],L2=[H2|T2], porownanie(T1,T2,I1),
- H1=\=H2,
- I is I1+1.
- hammond(X,Y,W) :-
- bintru(X,L1),
- bintru(Y,L2),
- length(L1,D1) , length(L2,D2), D1>D2,
- dopisywanie(L1,L2,L3), porownanie(L1,L3,W).
- hammond(X,Y,W) :-
- bintru(X,L1),
- bintru(Y,L2),
- length(L1,D1) , length(L2,D2), D1=<D2,
- dopisywanie(L1,L2,L3), porownanie(L3,L2,W).
- dop(L1,I,LW) :- I=:=0, LW=L1,!.
- dop(L1,I,LW) :- I1 is I-1,dop(L1,I1,TW), append(TW,[0],LW).
- dopisywanie2(L1,I,L2):- I=0,L2=L1,!.
- dopisywanie2(L1,I,L2):-
- I1 is I-1,
- dopisywanie2(L1,I1,L2A),
- append(L2A,[0],L2).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement