Advertisement
timothy235

sicp-1-3-2-constructing-procedures-using-lambda

Feb 17th, 2016
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Racket 0.47 KB | None | 0 0
  1. #lang racket
  2.  
  3. ;;;;;;;;;;
  4. ;; 1.34 ;;
  5. ;;;;;;;;;;
  6.  
  7. (define (f g)
  8.   (g 2))
  9.  
  10. (f sqr)
  11. ;; 4
  12. (f (lambda (z) (* z (add1 z))))
  13. ;; 6
  14.  
  15. ;; (f f) reduces to (f 2) which reduces to (2 2) which produces an error because 2
  16. ;; is not a procedure.
  17.  
  18. ;; (f f)
  19. ;; application: not a procedure;
  20.  ;; expected a procedure that can be applied to arguments
  21.   ;; given: 2
  22.   ;; arguments...:
  23.    ;; 2
  24.   ;; context...:
  25.    ;; C:\Program Files\Racket\collects\racket\private\misc.rkt:87:7
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement