50 lines
2.5 KiB
Prolog
50 lines
2.5 KiB
Prolog
/********************************/
|
|
/* Laboration 4 i Programspråk */
|
|
/* Prolog */
|
|
/********************************/
|
|
/* Christian Ohlsson */
|
|
/* Karlstads universitet 990525 */
|
|
/********************************/
|
|
|
|
|
|
book('C Lang', 'The C Programming Language', ['Kernighan B.W.', 'Ritchie D.M.'], 'Prentice Hall', '1988').
|
|
book('C Lang', 'From C to C: An Intro to ANSI Standard C', ['Gardner J.'], 'Harcourt:Brace Jovanovic', '1989').
|
|
book('Compilers', 'Compilers: Principles Techniques and Tools', ['Ullman J.D.', 'Aho A.V.', 'Sethi R.'], 'Addison Wesley', '1986').
|
|
book('Compilers', 'Compiler Design in C', ['Holub A.I.'], 'Prentice Hall', '1990').
|
|
book('Databases', 'An Introduction to Database Systems', ['Date C.J.'], 'Addison Wesley', '1995').
|
|
book('Databases', 'The Theory of Relational Databases', ['Maier D.'], 'Computer Science Press', '1983').
|
|
book('HCI', 'Human-Computer Interaction', ['Dix A.', 'Finlay J.', 'Abowd G.', 'Beale R.'], 'Prentice Hall', '1993').
|
|
book('Prog Langs', 'Programming Languages Concepts & Constructs', ['Sethi R.'], 'Addison Wesley', '1996').
|
|
book('Prog Langs', 'Concepts of Programming Languages', ['Sebesta R.W.'], 'Addison Wesley', '1996').
|
|
book('Prog Langs', 'Programming Languages Principles and Practice', ['Louden K.C.'], 'PWS Publishing', '1993').
|
|
|
|
run :- write_ln(' '),
|
|
write_ln(' ========================================== '),
|
|
write_ln(' Welcome to the database. '),
|
|
write_ln(' Type search(searchstring). to search '),
|
|
write_ln(' ========================================== '),
|
|
write_ln(' ').
|
|
|
|
subject(X) :- book(X,T,A,P,Y), printbook(X,T,A,P,Y), fail.
|
|
title(X) :- book(S,X,A,P,Y), printbook(S,X,A,P,Y), fail.
|
|
author(X) :- book(S,T,A,P,Y), member(X,A), printbook(S,T,X,P,Y), fail.
|
|
publisher(X) :- book(S,T,A,X,Y), printbook(S,T,A,X,Y), fail.
|
|
year(X) :- book(S,T,A,P,X), printbook(S,T,A,P,X), fail.
|
|
|
|
search(X) :- subject(X).
|
|
search(X) :- title(X).
|
|
search(X) :- author(X).
|
|
search(X) :- publisher(X).
|
|
search(X) :- year(X).
|
|
|
|
member(X,[X|_]).
|
|
member(X,[_|Y]) :- member(X,Y).
|
|
|
|
printbook(S,T,A,P,Y) :- write('Subject: '), write_ln(S),
|
|
write('Title: '), write_ln(T),
|
|
write('Author: '), write_ln(A),
|
|
write('Publisher: '), write_ln(P),
|
|
write('Year: '), write_ln(Y),
|
|
write_ln(' ').
|
|
|