Skip to content

Instantly share code, notes, and snippets.

@jbclements
Created October 1, 2018 18:13
Show Gist options
  • Save jbclements/96e0d61405b578fdb82e7006bc28c6c3 to your computer and use it in GitHub Desktop.
Save jbclements/96e0d61405b578fdb82e7006bc28c6c3 to your computer and use it in GitHub Desktop.
2018-10-01-morning.rkt
#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