Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ?- binaryHex('11111111',X).
- X = [f, f].
- ?- binaryHex(X,[f,f]).
- ERROR: atom_codes/2: Arguments are not sufficiently instantiated
- hex('0000',0).
- hex('0001',1).
- %etc
- hex('1111',f).
- binaryHex(X,Y) :-
- atom_codes(X,A),
- binaryList(A,B),
- binaryHex_(B,Y).
- binaryList([],[]).
- binaryList([A,B,C,D|Ds],[Y|Ys]) :-
- atom_codes(Y,[A,B,C,D]),
- binaryList(Ds,Ys).
- binaryHex_([],[]).
- binaryHex_([B|Bs],[H|Hs]) :-
- hex(B,H),
- binaryHex_(Bs,Hs).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement