PasteRack.org
Paste # 35080
2017-08-10 21:01:40

Fork as a new paste.

Paste viewed 110 times.


Embed:

Why does one work and one doesnt?

  1. #lang racket
  2.  
  3. ;my attempt in keeping track on the number of times a function is called
  4.  
  5. (define (make-counter)
  6.   (let ((counter 0))
  7.   (lambda()
  8.   (set! counter(add1 counter))
  9.     counter)))
  10.  
  11.  
  12. (define my-counter
  13.   (let ((count 0))
  14.     (lambda ()
  15.       (set! count (+ count 1))
  16.       count)))

=>