Skip to content

Instantly share code, notes, and snippets.

@jbclements
Created October 1, 2018 23:10
Show Gist options
  • Save jbclements/641bbf7393edff22bd8582d73e2f743b to your computer and use it in GitHub Desktop.
Save jbclements/641bbf7393edff22bd8582d73e2f743b to your computer and use it in GitHub Desktop.
lecture code from the afternoon class.
#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