Last modified: 2017-09-26
This is a course web page of
David Casperson
Associate Professor
Computer Science
University of Northern British Columbia

CPSC 370: Functional and Logic Programming ( )

Homework now due

No questions are yet due.

Pending homework questions

  1. Give two examples of Java syntactic sugar.
  1. How many partial functions are there from { Scissors, Paper, Rock, Spock, Lizard } 2 to { Win, Lose } ?

    Bonus: How many of these are fair and interesting?

  2. Implement a function that takes a pair of real numbers m and b and returns the linear function mx+b.
    • What is wrong with the wording above?
    • Implement this in Haskell.
    • Implement this in Racket.
    • Implement this in Java.
  • A Collatz sequence starts with an arbitrary positive integer n. The next number in the sequence is
    • 3n+1 if n is odd, and
    • n/2 if n is even.
    A sequence ends when n reaches 1.
  1. Write a Racket program that repeatedly asks the user for a starting number and then displays the resulting Collatz sequence.
  2. Add a way for the user to terminate the program.
  3. Write a similar program in Haskell.
  4. Add test functions to the Racket code by using (require rackunit) .
Home page Semesters Site Map
go back Fall 2017 go forward
2017-09 other links

CPSC 370 [Other years]
David’s Schedule

UNBC Undergraduate Calendar