CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 20:23:02 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=ad0ea9913f7b1904be9b8c5624f27af1b27fa34263e54f0326f37b8cefe0e15ba%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22iYmoVxp8FVW40XH7mLyM_cIac-1MbWLG%22%3B%7D; HttpOnly; Path=/
cf-ray: 98d112ac4b19dfa6-BLR
pred logic - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- male(james1).
- male(charles1).
- male(charles2).
- male(james2).
- male(george1).
- female(catherine).
- female(elizabeth).
- female(sophia).
- parent(charles1, james1).
- parent(elizabeth, james1).
- parent(charles2, charles1).
- parent(catherine, charles1).
- parent(james2, charles1).
- parent(sophia, elizabeth).
- parent(george1, sophia).
- mother(M,X):- parent(X,M),female(M),write(M),write(' is Mother of '),write(X),nl.
- father(F,X):- parent(X,F),male(F).
- sibling(S1,S2):- parent(S1,X), parent(S2,X).
- grandfather(G,X) :- parent(Y,G),parent(X,Y).
- Exercise -
- Implementation:
- Write a Prolog predicate reverse_list/2 that works like the built-in predicate
- reverse/2 (without using reverse/2).
- Program:
- % Base case: Reversing an empty list results in an empty list. reverse_list([], []).
- % Recursive case: To reverse a non-empty list, append the reversed tail to the head.
- reverse_list([Head|Tail], Reversed) :-
- reverse_list(Tail, ReversedTail),
- append(ReversedTail, [Head], Reversed).
- Write a Prolog predicate distance/3 to calculate the distance between two points in
- the 2-dimensional plane. Points are given as pairs of coordinates.
- Program:
- distance((X1, Y1), (X2, Y2), Distance) :-
- Distance is sqrt((X2 - X1) ** 2 + (Y2 - Y1) ** 2).
- Write a prolog program to solve Tower of hanoi Problem. Program:
- % Predicate to solve Tower of Hanoi problem hanoi(N) :-
- move(N, left, middle, right).
- % Predicate to move disks
- move(1, Source, _, Destination) :-
- write('Move top disk from '),
- write(Source),
- write(' to '),
- write(Destination), nl.
- move(N, Source, Auxiliary, Destination) :-
- N > 1,
- M is N - 1,
- move(M, Source, Destination, Auxiliary),
- move(1, Source, _, Destination),
- move(M, Auxiliary, Source, Destination).
- Write a Prolog predicate fibonacci/2 to compute the nth Fibonacci number.
- Program: fibonacci(0, 0).
- fibonacci(1, 1).
- fibonacci(N, Fib) :-
- N > 1,
- N1 is N - 1,
- N2 is N - 2,
- fibonacci(N1, Fib1),
- fibonacci(N2, Fib2),
- Fib is Fib1 + Fib2.
Advertisement
Add Comment
Please, Sign In to add comment
-
π Swapzone +37% glitch β V
JavaScript | 1 sec ago | 0.25 KB
-
β
β Make huge profits on trading ββ O
JavaScript | 10 sec ago | 0.25 KB
-
π΅ Make 3000$ in 20 minutes π΅
JavaScript | 12 sec ago | 0.24 KB
-
ββ
Marketplace Glitch β
Working β
NEVER SEEN...
JavaScript | 19 sec ago | 0.25 KB
-
π Swapzone +37% glitch
JavaScript | 23 sec ago | 0.24 KB
-
ββ
Exploit 2500$ in 15 Minutesβββ P
JavaScript | 28 sec ago | 0.25 KB
-
π Exchange profit method
JavaScript | 33 sec ago | 0.24 KB
-
Free Crypto Method (NEVER SEEN BEFORE)ββ G
JavaScript | 37 sec ago | 0.25 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand