?- nl. % new line, returns true.
?- write('a').
?- write(3).
?- X is 3 + 5, write(X).
% define this rule at the top of the .pl file, then call it like
% ?- cls.
cls :- write('\e[2J').
% Single line comment
/*
Mutli
Line
comment
*/
?- make.
?- assert(ite_student(ahmad)).
?- assert(happy(X) :- ite_student(X)).
?- happy(ahmad). % will return true
?- retract(ite-student(ahmad)).
?- retract(happy(X) :- ite-student(X)).
?- happy(ahmad). % will return false
halt.
write('Enter the first number: '), read(FirstNumber).
\+ rule.
not(rule).
Swi-Prolog -> Debug -> Graphical Debugger -> ?- trace.
-> some query -> use the arrows to step in/over the code.
- See testing_demo
(if -> then; else)
beware about the syntax
?- 3 =\= 4 % numeric comparasion
% true
?- 4 =\= 4
% false
?- ahmad \= ahmad. % string comparasion
% false
?- ahmad \= khaled.
% true
?- ahmad = ahmad
% true
?- (b\=a -> A=1; A=0)
% A = 1
?- (a\=a -> A=1; A=0)
% A = 0
?- ansi_format([fg(red)], 'This is in red', []).
% black, red, green, yellow, blue, magenta, cyan, white
?- ansi_format([bg(cyan)], 'This has a cyan background', []).
?- ansi_format([bg(cyan),fg(magenta),bold], 'We can mix them', []).
% reset, bold, fg(Color), bg(Color),...
?- ansi_format([], 'This also formats the string (~w = 5)', [5]).
:- use_module(library(theme/dark)).
% Or in the terminal/console
?- use_module(library(theme/dark)).