Created
October 1, 2018 23:10
-
-
Save jbclements/641bbf7393edff22bd8582d73e2f743b to your computer and use it in GitHub Desktop.
lecture code from the afternoon class.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang typed/racket | |
(require typed/rackunit) | |
(: my-list (Listof Number)) | |
(define my-list | |
(cons 6 (cons 12 (cons 13+4i (cons 16 '()))))) | |
; add the numbers in a list | |
(define (sum-up [l : (Listof Number)]) : Number | |
(match l | |
['() 0] | |
[(cons f r) (+ f (sum-up r)) ])) | |
(check-equal? (sum-up '()) 0) | |
(check-equal? (sum-up my-list) | |
47+4i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment