Advertisement
Guest User

Untitled

a guest
May 16th, 2015
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. :- module laba1.
  2. :- interface.
  3. :- import_module io.
  4. :- pred main(io::di, io::uo) is cc_multi.
  5. :- implementation.
  6. :- import_module int, list, string.
  7.  
  8. main(!IO) :-
  9. (if
  10. L = [0,1,2,3,4,5,6,7,8,9], L1 = list.tail(L),
  11. pick(L, A),
  12. pick(L, B),
  13. pick(L1, C),
  14. pick(L1, D),
  15. 51 * (10 * A + B) + 10 * C + D = 4905
  16. then
  17. io.format("a=%d, b=%d, c=%d, d=%d\n", [i(A), i(B), i(C), i(D)], !IO)
  18. else
  19. io.format("has no solutions", [], !IO)
  20. ).
  21.  
  22. :- pred pick(list(int)::in, int::out) is nondet.
  23. pick([X|_], X).
  24. pick([_|Xs], Y) :- pick(Xs, Y).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement