Advertisement
Guest User

Untitled

a guest
Jun 29th, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. ?- binaryHex('11111111',X).
  2. X = [f, f].
  3.  
  4. ?- binaryHex(X,[f,f]).
  5. ERROR: atom_codes/2: Arguments are not sufficiently instantiated
  6.  
  7. hex('0000',0).
  8. hex('0001',1).
  9. %etc
  10. hex('1111',f).
  11.  
  12. binaryHex(X,Y) :-
  13. atom_codes(X,A),
  14. binaryList(A,B),
  15. binaryHex_(B,Y).
  16.  
  17. binaryList([],[]).
  18.  
  19. binaryList([A,B,C,D|Ds],[Y|Ys]) :-
  20. atom_codes(Y,[A,B,C,D]),
  21. binaryList(Ds,Ys).
  22.  
  23. binaryHex_([],[]).
  24.  
  25. binaryHex_([B|Bs],[H|Hs]) :-
  26. hex(B,H),
  27. binaryHex_(Bs,Hs).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement