PasteRack.org
Paste # 14033
2019-05-07 23:49:40

Fork as a new paste.

Paste viewed 306 times.


Embed:

  1. #lang racket
  2.  
  3. (define (my-delay f)
  4.    (mcons #f f))
  5.  
  6. (define (my-force th)
  7.    (if (mcar th)
  8.        (mcdr th)
  9.        (begin (set-mcar! th #t)
  10.               (set-mcdr! th ((mcdr th)))
  11.               (mcdr th))))
  12.  
  13. (define th (my-delay (lambda () (+ 7 5))))
  14.  
  15. (define ans (my-force th))
  16.  
  17. (writeln ans)

=>

12