PasteRack.org
Paste # 11071
2019-04-05 00:09:52

Forked from paste # 75710.

Fork as a new paste.

Paste viewed 334 times.


Embed:

  1. #lang racket
  2. (define(volume-sphere radius)
  3.   (/ (* 4 3.14 radius radius radius) 3))
  4.  
  5.    (define (volume-shell inner-radius outer-radius)
  6.      (- (volume-sphere outer-radius) (volume-sphere inner-radius)))
  7.  
  8.    (volume-shell 1 2)
  9.    (volume-shell 3 5)
  10.  
  11. (define(close? number-1 number-2 limit)
  12.   (<(abs(- number-1 number-2))limit))
  13.  
  14.    (close? 5 4 1)
  15.    (close? 6 3 5)
  16.  
  17. (define (how-many a b c)
  18.   (cond [(> (* b b) (* 4 a c)) "2"]
  19.         [(= (* b b) (* 4 a c)) "1"]
  20.         [(< (* b b) (* 4 a c)) "0"]))
  21.  
  22.     (how-many 1 0 -1)
  23.     (how-many 2 4 2)

=>

29.306666666666665

410.29333333333335

#f

#t

"2"

"1"