.


:




:

































 

 

 

 





7.1.1. var, nonvar, atom, integer, float, number, atomic, compound

: , , .. , . , , , .. , . , , X Y, :

Z is X + Y


, X Y . , Y , .

number. number (X) , X , . , X " " . , , X Y, ( ) X Y:..., number! X), number (Yj', Z is X + Y,...

X, Y , . number "" 2 is + V ,

var, nonvar, atom, integer, float, number, atomic, compound. .

var{ X). , X -.

nonvar (X). , X ■ X .

atom(X). , X .

integer (X). , X .

float [X). , .

number (X). , X .

atomic (X). , X .

compound (X). , X ().

Prolog .

?- var (Z), Z = 2.

Z = 2

?- Z = 2, var(Z).

no

1- integer(Z), S = 2.

no

?- z = 2, integer[ z), nonvar[ z),

z - >

?- atom! 3.14).

no

?- atomic; 3.14).

yes

?- ata(== >;.

yes

?- ato(pd)). no

?- compound (2 + X)

yes



I. Prolog


atom . , , . :

count! A, L, )

, L , N . count :

count!, [], 0).

count [~Ar [AIL], ):-!,

count! A, L, N1), % HI N is N1 + 1. count! A, L 1 L], N):-count! A, L, .

:

?- count! , rarb,a,a], H). N = 3

?- count (a, [a,b,X,Y], Nat. - 3

?- count! , [a,b,X,Y], lib). Mb = 3

?- L = [, , X, ], count! a, L, Na), count [ , L, Nb).

Na = 3 Nb = 1

Y=a

X, Y , , a, = 1, . , , . count , . .

count (, [ | L], : -

atom! ), = ,!, % ?

count! a. Lr N1), \ ,
is Mi + 1

count (A, L, N). %

, nonvar.





:


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


:

:

- , - .
==> ...

1460 - | 1374 -


© 2015-2024 lektsii.org - -

: 0.013 .