fork download
  1. :- initialization(main).
  2.  
  3. ab(A,B) :- someFunc(A,B).
  4.  
  5. cd(1,5).
  6. cd('Some shit',4).
  7. cd(_,_) :- throw(bad_mapping). % gprolog-специфично
  8.  
  9. ef(e(X,Y), [X,Y]).
  10.  
  11.  
  12. someFunc(A,B) :- B is A * A.
  13.  
  14. main :-
  15. ab(5,B) , show(B)
  16.  
  17. , cd(C,4) , show(C)
  18. , catch(cd(3,_), bad_mapping, show('bad mapping!'))
  19.  
  20. , ef(e(4,'two'), F), show(F)
  21.  
  22. , halt
  23. .
  24. show(X) :- write(X), nl.
Success #stdin #stdout 0.02s 68352KB
stdin
Standard input is empty
stdout
25
Some shit
bad mapping!
[4,two]