Yalnız Mesajı Göster

Cevap : Prolog Örnekleri | Prolog Examples

Eski 04-07-2009   #4
[KAPLAN]
Varsayılan

Cevap : Prolog Örnekleri | Prolog Examples



Lecture 7


Program 71 - a simple course database program


semester2_1 -->
mod, mod, mod, mod,
prog_option,
options2_1

options2_1 -->
option
options2_1 -->
elective

mod --> [sem222]
mod --> [sem236]
mod --> [sem240]
mod --> [sem232a]

prog_option --> [sem241]
prog_option --> [sem242]

elective --> [comm271]

option --> [sem227]
option --> [sem2a2]


Program 72 - a simple course database program that checks the name of the student


semester2_1(Student) -->
mod(Student),
mod(Student),
mod(Student),
mod(Student),
prog_option(Student),
options2_1(Student)

options2_1(Student) -->
option(Student)
options2_1(Student) -->
elective(Student)

mod(james) --> [sem222]
mod(james) --> [sem236]
mod(james) --> [sem240]
mod(james) --> [sem232a]

prog_option(james) --> [sem242]

elective(james) --> [comm271]

option(ben) --> [sem227]


Program 73 - a simple course database program that checks the name of the student and calculates a total mark


semester2_1(Student, Total_Mark) -->
mod(Student, Mark1),
mod(Student, Mark2),
mod(Student, Mark3),
mod(Student, Mark4),
prog_option(Student, Mark5),
options2_1(Student, Mark6),
{ Total_Mark is Mark1 + Mark2 + Mark3 +
Mark4 + Mark5 + Mark6 }

options2_1(Student, Mark) -->
option(Student, Mark)
options2_1(Student, Mark) -->
elective(Student, Mark)

mod(james, 57) --> [sem222]
mod(james, 53) --> [sem236]
mod(james, 62) --> [sem240]
mod(james, 55) --> [sem232a]

prog_option(james, 95) --> [sem242]

elective(james, 68) --> [comm271]

option(ben, 54) --> [sem227]


Program 74 - a demonstration of how to build a structure representiong an object

This technique is often used to represent syntactic structure in grammar but can equally well work for other things This example is the structure of a door
doors(door(Panel, Hinges, Lock)) -->
hinges(Hinges),
door_panel(Panel),
lock(Lock)


hinges(hinge(brass, 3)) -->
[hinge]
hinges(hinge(steel, 2)) -->
[hinge]

door_panel(panel(white)) -->
[panel]
door_panel(panel(wood_effect)) -->
[panel]

lock(lock(yale)) -->
[lock]

Alıntı Yaparak Cevapla