-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLesson6.pl
More file actions
36 lines (28 loc) · 1.02 KB
/
Lesson6.pl
File metadata and controls
36 lines (28 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
% Lesson 6 - Built-in operations
% member - check whether the student enroll for that subject or not
enrol(ridzuan,[logic_programming,
artificial_intelligence,
mathematics,statistic]).
enrol(syahidah,[artificial_intelligence,
mathematics,
fuzzy_logic,
taekwando]).
enrol(mira,[mathematics,
fuzzy_logic,
creative_writing,
internet_technology]).
enrol(kamarul,[fuzzy_logic,
creative_writing,
digital_circuit,
electric_electronic]).
enrol(mohd_ali, [digital_circuit,
electric_electronic,
robotics_automation]).
check(X,Y):- enrol(X,S),member(Y,S).
% append - insert new subject in the student’s list
insert(X,Y):- enrol(X,S), append([Y],S,N),writeln(N).
% delete/select - drop a subject from the list that a student has enrolled into
%drop(X,Y):- enrol(X,S),delete(S,Y,N),writeln(N).
drop(X,Y):- enrol(X,S),select(Y,S,N),writeln(N).
% reverse - check list whether is a palindrome (reads the same in the forward and in the backward direction)
palindrome(L):- reverse(L,L).