CS 331 Spring 2026  >  Assignment 7 (Coding in Scheme & Prolog)


CS 331 Spring 2026
Assignment 7 (Coding in Scheme & Prolog)

Assignment 7 is due at 5 pm Thursday, April 23. (Note that, as per the syllabus, this assignment will not be accepted after the beginning of the final exam period: 3:15 pm Wednesday, April 29.) The assignment is worth 75 points.

Procedures

This assignment is to be done individually.

Turn in answers to the exercises below on the UA Canvas site, under Assignment 7 for this class.

Exercises (A–D, 75 pts total)

There will be no test programs posted for this assignment. Test your code!

Exercise A — Running a Tamandua Program

Purpose

In this exercise you will demonstrate that you can execute Tamandua code.

Instructions

Get the file check_tamandua.tdua from the class Git repository. This is a Tamandua source file for a complete program. When it is executed, this program prints “Secret message #5:”. Below that, it prints a secret message. Run the program. What is the secret message?

To execute the program, run tamandua.lua, with the following files in the same directory: check_tamandua.tdua, from the Git repository, and lexit.lua, parseit.lua, and interpit.lua, from previous assignments. At the prompt, type:

:r check_tamandua.tdua

Exercise B — Programming in Scheme

Purpose

In this exercise, you will write a Scheme procedure.

Instructions

Write a Scheme source file alternatingsums.scm as follows. Be sure to follow the Coding Standards.

Exercise C — Programming in Prolog

Purpose

In this exercise, you will write a Prolog predicate.

Instructions

Write a Prolog source file collcount.pl as follows. Be sure to follow the Coding Standards.

Exercise D — Writing a Tamandua Program

Purpose

In this exercise, you will write a program in Tamandua, the programming language that you have written an interpreter for in previous assignments.

Instructions

Write a complete Tamandua program in source file fact.tdua, as follows. Be sure to follow the Coding Standards.