.


:




:

































 

 

 

 


Print_countries




Goal print_countries.

, , fail print_countries . , print_countries .

4. .

predicates

solve(real, real, real) %

reply(real, real, real) %

mysqrt(real, real, real) %

equal(real, real) %

clauses

solve(A, B, C): D = B*B-4*A*C, %

reply(A, B, D), nl.

reply(_, _, D): D < 0, write("No solution"),!.

reply(A, B, D): D = 0, X=-B/(2*A), write("x=", X),!.

reply(A, B, D):

sqrt(D, D, SqrtD),

X1 = (-B + SqrtD)/(2*A),

X2 = (-B SqrtD)/(2*A),

write("x1 = ", X1," and x2 = ", X2).

Goal solve(3,4,5).

5. . .

. . . , , , , . , , . , , . , . . , . (: ).

Predicates

Cat(string)

Dog(string)

Color(string,string)

Have(string,string)

Rod(string)

Animal(string)

Clauses

Cat(butsi). cat(korni). cat(mac).

dog(rover). dog(fles). dog(spot).

Color(butsi,brown).

Color(korni,black).

Color(mac,yellow).

Color(rover,yellow).

Color(spot,white).

color(fles,black_and_white).

have(tom,X):color(X,black); color(X,brown).

have(keit,X):dog(X), not(color(X,white)), not(have(tom,X)).

have(alan,mac):not(have(keit,butsi)), not(rod(spot)).

rod(X):animal(X), have(tom,X).

rod(X):animal(X), have(keit,X).

animal(X):cat(X); dog(X).

Goal animal(X),not(have(_,X)),write(X).

, , , . , , , .

6. . H :

Domains

N, F=real

Predicates

Factorial(N,F)





:


: 2015-10-01; !; : 501 |


:

:

, .
==> ...

1672 - | 1537 -


© 2015-2024 lektsii.org - -

: 0.008 .