Saturday, 16 March 2019

Simple Programming In Prolog

We can make a simple program with prolog. For example, calculate the area of a rectangle. Attention to the picture below;

 
In prolog, we can complete a simple program. Let's do it!


% Fact 

the_retangle_have( long, 10).
the_retangle_have( wide, 6).


%Rule 

the_ area_of_a_rectangle(A):-
                                                 the_retangle_have( long, L),the_retangle_have( wide, W),
                                                 A is L*W.

 
 

No comments:

Post a Comment

Note: only a member of this blog may post a comment.