read , read] X)
, , X. X , X , , read { X) . read , . ( ).
read | X; , end_of_file.
write ,
write (X!
X . X , Prolog . Prolog , write "" , , .
, Prolog , . ,
tab[ )
N , ] ( ) .
.
, , : cube{ , ):- is * * N.
, . .
?- cube(2,X).
?- cube (5, Y). Y - 125
?- cube[12, Z). Z = 1728
, , cube . , stop:
cube: -read: X), process (X).
orocess{ stop!:-!. process (N):-
6.
is N N , write [ ), cube.
- , . : cube, X, ; X = stop, , X cube . :
?- cube.
2.
-
5.
12.
stop, yes
2, 5 12; . , , , , .
|
|
, cube. :
cube: -
read! stop),!.
cube: - read [ N),
is N * N * N, write (C), cube.
, , , , 5. reacH stop) . read . , , stop read (N), .
cube . , , , , , . . cube , , . cube:-
writef "Uext item, please: '], read(x),
process! X).
process! stop);-!. process { N):-
is N ' N,
write ('Cube of '), write! N), write! ' is '),
write! C), nl,
cube.
cube , , :
140 I. Prolog
?- cube.
(text Itea. please: 5.
Cube of 5 is 125
Next item, please; 12.
Cube of 12 is 1728
next item, please: stop.
yes
Prolog, (, ttyf lush), .
, .