Created
October 1, 2018 18:13
-
-
Save jbclements/96e0d61405b578fdb82e7006bc28c6c3 to your computer and use it in GitHub Desktop.
2018-10-01-morning.rkt
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 | |
(define my-list | |
(cons 3 | |
(cons 4 (cons "horse" (cons (cons 16 '()) | |
'()))))) | |
;; determine the length of a list | |
(define (mylen [l : (Listof Any)]) : Natural | |
(match l | |
[(cons f r) (add1 (mylen r))] | |
['() 0])) | |
(require typed/rackunit) | |
(check-equal? (mylen '()) 0) | |
(check-equal? (mylen my-list) 4) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment