1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| ;;The multiplication is saved but not executed
(define my-promise (delay (* 5 6 7 8 9)))
;;Again, saved but not executed
(define another-promise (delay (sqrt 9)))
;;Forces the multiplication to execute. Saves and returns the value
(display (force my-promise))
(newline)
;;This time, the multiplication doesn't have to execute. It just returns
;;the value that was previously saved.
(display (force my-promise))
(newline)
;;This produces an error, because the promise must be forced to be used
(display (+ my-promise (force another-promise)))
|