PasteRack.org
Paste # 22178
2017-01-16 22:18:49

Fork as a new paste.

Paste viewed 548 times.


Embed:

  1. #lang racket
  2. (define make-pi
  3.   (lambda (acc)
  4.     make-pi-help(4.0 4.0 1.0 acc)))
  5.  
  6. (define make-pi-help
  7.   (lambda (sum num denom acc)
  8.     (if (> acc (abs sum))
  9.         0
  10.         (+ sum
  11.            make-pi-help((/ (* num -1) (+ denom 2))
  12.                         (* num -1)
  13.                         (+ denom 2)
  14.                         acc)
  15.            ))))
  16.  
  17. ;this should output 3.0916238066678385
  18. (make-pi 0.1)
  19.  
  20. ;this should output 3.1410926536210435
  21. (make-pi 0.001)

=>

application: not a procedure;

 expected a procedure that can be applied to arguments

  given: 4.0

  arguments...:

   4.0

   1.0

   0.1

application: not a procedure;

 expected a procedure that can be applied to arguments

  given: 4.0

  arguments...:

   4.0

   1.0

   0.001