From 10237b7386c294beeea1eab14b9d38c82cdfa2b1 Mon Sep 17 00:00:00 2001 From: Peter Date: Sun, 6 Aug 2023 17:51:54 +0800 Subject: [PATCH] Lab 1 --- README.md | 5 +++++ hello_world.pl | 3 +++ lab1-logic-programming.pl | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 README.md create mode 100644 hello_world.pl create mode 100644 lab1-logic-programming.pl 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 + ).