define3.scm 628 B

12345678910111213141516171819202122
  1. ;; Kawa-options: "--no-inline" "-f" %F
  2. ;; Test extracted from test.scm, originally r4rstest.scm by Aubrey Jaffer.
  3. (define add3 (lambda (x) (+ x 3)))
  4. (format #t "add3 3: ~w~%" (add3 3))
  5. ;; Output: add3 3: 6
  6. (define first car)
  7. (format #t "first 1 2: ~w~%" (first '(1 2)))
  8. ;; Output: first 1 2: 1
  9. (define old-+ +)
  10. (begin (begin (begin)
  11. (begin (begin (begin) (define + (lambda (x y) (list y x)))
  12. (begin)))
  13. (begin))
  14. (begin)
  15. (begin (begin (begin) (format #t "add3 6: ~w~%" (add3 6))
  16. (begin))))
  17. ;; Output: add3 6: (3 6)
  18. (set! + old-+)
  19. (format #t "add3 6: ~w~%" (add3 6))
  20. ;; Output: add3 6: 9