PasteRack.org
Paste # 74110
2015-12-09 18:29:28

Fork as a new paste.

Paste viewed 1036 times.


Embed:

Inv

  1. #lang racket
  2. (require math)
  3. (require racket/match)
  4.  
  5. (define (inverse func)
  6.   (match func
  7.     ['exp log]
  8.     ['cos acos]
  9.     [_ #f]))
  10.  
  11. (printf "Inv[~a](~a) = ~a\n" 'exp (exp 1) ((inverse 'exp) (exp 1)))
  12. (printf "Inv[~a](~a) = ~a" 'cos 1 ((inverse 'cos) 1))

=>

Inv[exp](2.718281828459045) = 1.0

Inv[cos](1) = 0