Here is code fragment containing bla-bla(branch-1;branch2 ) finish1;catch_all :
Code: Select all
predicates
onMouseDown : window::mouseDownListener.
% Original clause
clauses
onMouseDown(_Source, Point, _ShiftControlAlt, _Button) :-
Point = pnt(X0,Y0),
X = X0-x, Y = Y0-d,
X>0, Y>0,
X<field, Y<field,!,
I = X div cell_size,
J = Y div cell_size,
(
cell(step,I,J),
retract(cell(step,I,J)),
aliveN := aliveN-1,
showXY(I,J,empty),!;
assert(cell(step,I,J)),
aliveN := aliveN+1,
showXY(I,J,life)
),
integerControl1_ctl:setInteger(aliveN);
succeed.
Code: Select all
%1
onMouseDown(_Source, Point, _ShiftControlAlt, _Button) :-
Point = pnt(X0,Y0),
X = X0-x, Y = Y0-d,
X>0, Y>0,
X<field, Y<field,!,
I = X div cell_size,
J = Y div cell_size,
cell(step,I,J),
retract(cell(step,I,J)),
aliveN := aliveN-1,
showXY(I,J,empty),!,
integerControl1_ctl:setInteger(aliveN),!.
%2
onMouseDown(_Source, Point, _ShiftControlAlt, _Button) :-
Point = pnt(X0,Y0),
X = X0-x, Y = Y0-d,
X>0, Y>0,
X<field, Y<field,!,
I = X div cell_size,
J = Y div cell_size,
assert(cell(step,I,J)),
aliveN := aliveN+1,
showXY(I,J,life)
integerControl1_ctl:setInteger(aliveN),
!.
%3
onMouseDown(_Source, Point, _ShiftControlAlt, _Button) :-
succeed.
I remember from the manual that ";" means "or" but I do not remember such usage of pairs of parentheses within a clause body.