Skip to content

Commit

Permalink
Lesson 5
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamled committed Apr 6, 2019
1 parent 1af1542 commit abcd3f6
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lesson-5/contracts.rkt
@@ -0,0 +1,19 @@
#lang racket

(define/contract (f x)
(exact-integer? . -> . exact-integer?)
(* x (add1 x)))

(define (infinite? n)
(or (= +inf.0)
(= +inf.f)
(= -inf.0)
(= -inf.f)))

(define/contract (cool x y)
(real? real? . -> . (or/c exact-integer?
infinite?))
(define m (max (ceiling x) (ceiling y)))
(if (infinite? m)
m
(f (inexact->exact m))))

0 comments on commit abcd3f6

Please sign in to comment.