UNB/ CS/ David Bremner/ tags/ cs3613

This feed contains pages with tag "cs3613".

The final exam, worth 50% of your mark, is tentatively scheduled for 7PM on April 22.

Details about topics will be added to this page closer to the date of the test.

Posted Sat 08 Apr 2017 09:00:00 AM ADT Tags: /tags/cs3613

The second midterm, worth 15% of your mark, will be held in class on March. 14, 2017.

Details about topics will be added to this page closer to the date of the test.

Posted Tue 14 Mar 2017 12:30:00 PM ADT Tags: /tags/cs3613

The first midterm, worth 15% of your mark, will be held in class on Feb. 7, 2017.

Details about topics will be added to this page closer to the date of the test.

Posted Tue 07 Feb 2017 11:30:00 AM AST Tags: /tags/cs3613

Part 1

For each of the following code samples, add sufficient test forms to get full coverage

Sample 1

#lang plai-typed
(define (digit-num n)
  (cond [(<= n 9)    (some 1)]
        [(<= n 99)   (some 2)]
        [(<= n 999)  (some 3)]
        [(<= n 9999) (some 4)]
        [else        (none)]))

Sample 2

#lang plai-typed
(define (helper n acc)
  (if (zero? n)
    acc
    (helper (- n 1) (* acc n))))

(define (fact n)
  (helper n 1))

Sample 3

For the parser example, you'll need to peruse the documentation on expressions to figure out how to test for errors. You may also find the S-expression documentation helpful in constructing test input.

#lang plai-typed
(define-type AE
  [Num (n : number)]
  [Add (l : AE) (r : AE)]
  [Sub (l : AE) (r : AE)])
(define (parse [s : s-expression])
  (cond
     [(s-exp-number? s) (Num (s-exp->number s))]
     [(s-exp-list? s)
      (let* ([sl (s-exp->list s)]
             [op (s-exp->symbol (first sl))]
             [left (second sl)]
             [right (third sl)])
        (case op
          [(+) (Add (parse left) (parse right))]
          [(-) (Sub (parse left) (parse right))]))]
     [else (error 'parse-sexpr "bad syntax")]))

Part 2

Sample 3 has several bugs, namely syntax errors that crash the parser, rather than generate error messages about the input. Correct at least one of these bugs, and add a suitable test.

Posted Mon 16 Jan 2017 08:30:00 AM AST Tags: /tags/cs3613

Part 1

Follow the instructions at racket-setup to get racket set up for this course. If the system version of drracket is not available (e.g. in the menus) yet, then you can start drracket by opening a terminal and running

  % ~bremner/bin/drracket

Part 2

Do the Quick racket tutorial. Although you can just copy and paste the text into DrRacket, you will get more benefit from typing things in and more importantly from changing things and observing the results.

Posted Mon 09 Jan 2017 08:30:00 AM AST Tags: /tags/cs3613