as3.pdf - CPSC 312 Functional and Logic Programming Fall 2017 Assignment Three Functions and Relations Due 11:59pm Sunday 24 September 2017 Submit

# as3.pdf - CPSC 312 Functional and Logic Programming Fall...

This preview shows page 1 - 2 out of 2 pages.

CPSC 312 Functional and Logic Programming Fall 2017 Assignment Three: Functions and Relations Due: 11:59pm, Sunday 24 September 2017. Submit solution to Canvas Submit your answers in text files to Canvas. Use proper sentences in your answers. Make sure you name, student number is at the top of each file. You need to hand in a program that runs with SWI Prolog (including the intended interpretation for all symbols, and some test cases) with all other answers as comments. Question One Suppose that times are represented as am ( H , M ) for the time M minutes after hour H in the morning or as pm ( H , M ) for M minutes after hour H in the afternoon. For example, am (11 , 30) is 11:30 in the morn- ing, pm (1 , 30) is 1:30 in the afternoon, and pm (12 , 30) is halfway between these times. Write a predicate before ( T 1 , T 2) that is true when time T 1 is before time T 2 . You can only use the built-in predicate < , which compares two numbers. Question Two (a) Write a program del 1( E , L , R ) which is true when R is a list with the same elements as list L (in the