string.scm 551 B

12345678910111213141516171819202122232425
  1. ;;; From from http://www.ccs.neu.edu/home/will/Twobit/KVW/string.txt .
  2. ; string test
  3. ; (try 100000)
  4. (define s "abcdef")
  5. (define (grow)
  6. (set! s (string-append "123" s "456" s "789"))
  7. (set! s (string-append
  8. (substring s (quotient (string-length s) 2) (string-length s))
  9. (substring s 0 (+ 1 (quotient (string-length s) 2)))))
  10. s)
  11. (define (trial n)
  12. (do ((i 0 (+ i 1)))
  13. ((> (string-length s) n) (string-length s))
  14. (grow)))
  15. (define (try n)
  16. (do ((i 0 (+ i 1)))
  17. ((>= i 10) (string-length s))
  18. (set! s "abcdef")
  19. (trial n)))
  20. (try 50000000)