all about me: prolog (LP)
...SELAMAT DATANG ...TERIMA KASIH ...TELAH BERKUNJUNG
RSS

prolog (LP)

contoh program kondisi pada prolog.
1. depan(A, A) :- A < 10.


depan(A, B) :-

A1 is A // 10,

depan(A1, B1),

B is B1.



output :

Input : ?- depan(256, X).



Output : Yes. X = 2.





2. contoh perulangan pada prolog.
loop(N):-N>0,write('The value is: '),write(N),nl,


M is N-1,loop(M).



output:

?- loop(6).

The value is: 6

The value is: 5

The value is: 4

The value is: 3

The value is: 2

The value is: 1

yes

1 comments:

Unknown said...

thanks ilmunya gan

Post a Comment