<?xml version="1.0"?>
<paste-with-annotations>
  <paste>
    <number>
      <integer>52419</integer>
    </number>
    <user>
      <string>bsmntbombdood</string>
    </user>
    <title>
      <string>foo</string>
    </title>
    <contents>
      <string>(define (print-chars tape chars)
  (if (null? chars)
      &quot;&quot;
      (shortest
       (map (lambda (using-cell)
	      (let* ((data (print-char tape (car chars) using-cell))
		     (new-tape (cdr data))
		     (code (car data)))
		(string-append code
			       (print-chars new-tape (cdr chars)))))
	    (from-to 0 (- (vector-length (tape-cells tape)) 1))))))

      
(define (print-char tape char using-cell)
  (cons 
   (string-append (if (&lt; using-cell (tape-pos tape))
		      (make-string (- (tape-pos tape) using-cell) #\&lt;)
		      (make-string (- using-cell (tape-pos tape)) #\&gt;))
		  (if (&lt; char (vector-ref (tape-cells tape) using-cell))
		      (make-string (- (vector-ref (tape-cells tape) using-cell) char) #\-)
		      (make-string (- char (vector-ref (tape-cells tape) using-cell)) #\+))
		  &quot;.&quot;)
   (make-tape (let ((v (vector-copy (tape-cells tape))))
		(vector-set! v using-cell char)
		v)
	      using-cell)))

(define (from-to n m)
  (if (= n m)
      (list n)
      (cons n (from-to (+ n 1) m))))

(define (shortest lst)
  (let loop ((lst lst)
	     (shortest #f)
	     (len #f))
    (cond ((null? lst) shortest)
	  ((or (not shortest) (&lt; (string-length (car lst)) len))
	   (loop (cdr lst)
		 (car lst)
		 (string-length (car lst))))
	  (else (loop (cdr lst) shortest len)))))


(define (initialize-factors factor num)
  (make-factors (make-tape (let ((v (make-vector (+ num 1) 0))) (vector-set! v 0 factor) v)
			   0)
		factor
		num))


  
(define (make-factors tape factor num)
  (set! tape (make-tape (vector-copy (tape-cells tape)) (tape-pos tape)))
  (let loop ((i 1))
    (if (&lt; i (+ num 1))
	(begin
	  (vector-set! (tape-cells tape)
		       i
		       (* i (vector-ref (tape-cells tape) (tape-pos tape))))
	  (loop (+ i 1)))))
  (vector-set! (tape-cells tape) (tape-pos tape) 0)
  (cons tape
	(call-with-output-string
	 (lambda (out)
	   (write-string (make-string factor #\+) out)
	   (write-string &quot;[&quot; out)
	   (let loop ((n 1))
	     (if (&gt; n num)
		 (write-string (make-string num #\&lt;) out)
		 (begin (write-string &quot;&gt;&quot; out)
			(write-string (make-string n #\+) out)
	       (loop (+ n 1)))))
	   (write-string &quot;-]&quot; out)))))


(define (print-string string)
  (shortest
   (map
    (lambda (factor)
      (let* ((data (initialize-factors factor (min (min 8 (floor (/ 256 factor))))))
	     (tape (car data))
	     (code (cdr data)))
	(string-append code
		       (print-chars tape
				    (map char-&gt;integer
					 (string-&gt;list string))))))
    (from-to 2 256))))</string>
    </contents>
    <universal-time>
      <integer>3406513855</integer>
    </universal-time>
    <channel>
      <string>#lispcafe</string>
    </channel>
    <colorization-mode>
      <string>Scheme</string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <null/>
    </is-unicode>
  </paste>
</paste-with-annotations>