9618/31/M/J/22 question 2: worked solution (May/June 2022, paper 31)

Show as plain text

Cambridge A2 Level Computer Science 9618 · 20.1 Programming Paradigms Worked solution from the Further Programming Paper 3 Advanced Theory booklet, Part 1 of 2. Q3 9618/31/M/J/22 original Q2 Structured · 6 marks Worked solution (a) A caracal is a wild cat, so write a type fact. It has short hair, so write a hair fact. Each ends with a full stop. type(caracal, wild). hair(caracal, short). Clause 18 is type(caracal, wild). [1] Clause 19 is hair(caracal, short). [1] (b) Only clause 11 has long hair (persian). Write: Cat = persian [1] (c)(i) Use the variable in the first place of the type clause. type(Pet, domestic). Write: type(Pet, domestic). [1] (c)(ii) Both conditions must be true for the same cat, so join two clauses with a comma (AND). spots(WildSpotty, yes), type(WildSpotty, wild). Both clauses use WildSpotty in the correct place [1] The two clauses are joined with a comma and the goal ends with a full stop [1] The two clauses may be written in either order. KEY IDEA Facts have the form predicate(item, value). A goal with a variable finds matches, and a comma joins goals that must all be true. TOTAL 6 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by qiphyedu. Tap the picture to open it on YouTube.