commit 10237b7386c294beeea1eab14b9d38c82cdfa2b1 Author: Peter Date: Sun Aug 6 17:51:54 2023 +0800 Lab 1 diff --git a/README.md b/README.md new file mode 100644 index 0000000..3359df3 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# CITS3007 labs + +All labs are not assessed and are freely available online, therefore this does not constitute misconduct. + +https://teaching.csse.uwa.edu.au/units/CITS3005/ diff --git a/hello_world.pl b/hello_world.pl new file mode 100644 index 0000000..883925a --- /dev/null +++ b/hello_world.pl @@ -0,0 +1,3 @@ +main :- write('hello world'). +# run file with +# [hello_world], main. \ No newline at end of file diff --git a/lab1-logic-programming.pl b/lab1-logic-programming.pl new file mode 100644 index 0000000..763f75d --- /dev/null +++ b/lab1-logic-programming.pl @@ -0,0 +1,33 @@ +% Lab 1 - logic programming +% LABSHEET: +% https://teaching.csse.uwa.edu.au/units/CITS3005/labs/lab01-logic-programming.pdf + +student(jane). +student(tim). +student(cris). + +unit(cits3005). +unit(cits2211). + +prerequisite(cits2211,cits3005). + +mark(cits3005,jane,Result) :- Result is 50. +mark(cits2211,jane,Result) :- Result is 57. + +mark(cits2211,tim,Result) :- Result is 30. + +mark(cits2211,cris,Result) :- Result is 60. + +eligible(Student,Unit) :- + student(Student), + unit(Unit), + ( + % CASE 1: Unit has no prerequisites + \+ prerequisite(_, Unit), + !; + + % CASE 2: Unit has prerequisites AND Student's mark in the prerequisite unit >= 50 + prerequisite(PreUnit,Unit), + mark(PreUnit,Student,Result), + Result >= 50 + ).