append.scm 782 B

123456789101112131415161718192021222324252627
  1. ;;; append: an example Pre-Scheme program
  2. (define (main argc argv)
  3. (if (= argc 3)
  4. (let ((out (current-output-port))
  5. (a (vector-ref argv 1))
  6. (b (vector-ref argv 2)))
  7. (demo-string-append a a out)
  8. (demo-string-append a b out)
  9. (demo-string-append b b out)
  10. 0)
  11. (let ((out (current-error-port)))
  12. (write-string "Usage: " out)
  13. (write-string (vector-ref argv 0) out)
  14. (write-string " <string-a> <string-b>" out)
  15. (newline out)
  16. (write-string " Prints permutations of <string-a> and <string-b>." out)
  17. (newline out)
  18. 1)))
  19. (define (demo-string-append a b out)
  20. (let ((str (string-append a b)))
  21. (write-string str out)
  22. (newline out)
  23. (deallocate str)
  24. #t))