<?xml version="1.0"?>
<paste-with-annotations>
  <paste>
    <number>
      <integer>59441</integer>
    </number>
    <user>
      <string>jdrake</string>
    </user>
    <title>
      <string>First paste in 2 months here!</string>
    </title>
    <contents>
      <string>(define (within? x lower upper)
  (and (&lt;= x upper) (&gt;= x lower)))

; rotate-char char amount lower upper -&gt; char
; If char is within lower and upper range, increase char by amount, and if
; it goes over the upper range, then wrap around to the lower range.

(define (rotate-char in amount lower upper)
  (let
      ((in (char-&gt;integer in))
       (lower (char-&gt;integer lower))
       (upper (char-&gt;integer upper)))
    (integer-&gt;char
     (if (within? in lower upper) 
         (begin
           (set! in (+ in amount))
           (if (&gt; in upper)
               (+ lower (- in upper) -1) 
               in))
         in))))


(define (rot13 in)
  (cond 
      ((char-lower-case? in) (rotate-char in 13 #\a #\z))
      ((char-upper-case? in) (rotate-char in 13 #\A #\Z))
      (else in)))


; I am not sure I want to think about this for now...
;(define (rotate-char2 in amount lower upper)
;  (let loop ((i in)) 
;    (cond 
;      ((&lt; i lower) (loop (+ i amount)))
;      ((&lt; i upper) i)
;      (else (loop (+ lower (- i upper)))))))
</string>
    </contents>
    <universal-time>
      <integer>3417743586</integer>
    </universal-time>
    <channel>
      <string>#lispcafe</string>
    </channel>
    <colorization-mode>
      <string></string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <null/>
    </is-unicode>
  </paste>
  <annotation>
    <number>
      <integer>8</integer>
    </number>
    <user>
      <string>offby1</string>
    </user>
    <title>
      <string>Mister Gorbachov, rewrite &quot;within&quot;</string>
    </title>
    <contents>
      <string>(define (within? x lower upper) 
    (&lt;= lower x upper))</string>
    </contents>
    <universal-time>
      <integer>3417748718</integer>
    </universal-time>
    <channel>
      <string>#lispcafe</string>
    </channel>
    <colorization-mode>
      <string></string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <null/>
    </is-unicode>
  </annotation>
  <annotation>
    <number>
      <integer>7</integer>
    </number>
    <user>
      <string>offby1</string>
    </user>
    <title>
      <string>my scary hairy dense version!! I still prefer it.</string>
    </title>
    <contents>
      <string>(define (rot13-char c)
  (cond
   ((char-alphabetic? c)
    (let ((upper? (char-upper-case? c))
           (c (char-downcase c)))
      ((if upper?
           char-upcase
           values)
       (integer-&gt;char (+ (char-&gt;integer #\a)
                         (remainder (+ 13 (- (char-&gt;integer c)
                                             (char-&gt;integer #\a))) 26))))))
   (else
    c)
   ))
</string>
    </contents>
    <universal-time>
      <integer>3417748501</integer>
    </universal-time>
    <channel>
      <string>#lispcafe</string>
    </channel>
    <colorization-mode>
      <string></string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <null/>
    </is-unicode>
  </annotation>
  <annotation>
    <number>
      <integer>6</integer>
    </number>
    <user>
      <string>offby1</string>
    </user>
    <title>
      <string>ports</string>
    </title>
    <contents>
      <string>(define (rot13-stream in out)
  (let loop ()
    (let ((ch (read-char in)))
      (when (not (eof-object? ch))
        (display (rot13-char ch) out)
        (loop)))))
</string>
    </contents>
    <universal-time>
      <integer>3417748268</integer>
    </universal-time>
    <channel>
      <string>#lispcafe</string>
    </channel>
    <colorization-mode>
      <string></string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <null/>
    </is-unicode>
  </annotation>
  <annotation>
    <number>
      <integer>5</integer>
    </number>
    <user>
      <string>jdrake</string>
    </user>
    <title>
      <string>Preliminary Final Code: Comments?</string>
    </title>
    <contents>
      <string>#!/usr/bin/env mzscheme

; Special thanks to Vixey in #lispcafe

; within? x lower upper
; Is x is within lower to upper?
(define (within? x lower upper)
  (&lt;= lower x upper))

; wrap-range x lower upper
; If x is above range, it will wrap from lower
; If x is below range, it will wrap from upper
; It will repeat if necessary
(define (wrap-range x lower upper)
  (cond
    ((&gt; x upper) (wrap-range (+ lower (- x upper) -1) lower upper))
    ((&lt; x lower) (wrap-range (- upper (- lower x) -1) lower upper))
    (else x))) 

; rotate-char char amount lower upper -&gt; char
; If char is within lower and upper range, increase char by amount, and if
; it goes over the upper range, then wrap around to the lower range.
(define (rotate-char x amount lower upper)
  (let
      ((x (char-&gt;integer x))
       (lower (char-&gt;integer lower))
       (upper (char-&gt;integer upper)))
    (integer-&gt;char
     (if (within? x lower upper) 
         (wrap-range (+ x amount) lower upper)
         x))))

; rot13 x
; Converts char x to its rot13 equivalent
(define (rot13 x)
  (cond 
      ((char-lower-case? x) (rotate-char x 13 #\a #\z))
      ((char-upper-case? in) (rotate-char x 13 #\A #\Z))
      (else x)))

; rot13-string string
; Converts a string to its rot13 equivalent
(define (rot13-string string)
  (list-&gt;string (map rot13 (string-&gt;list string))))</string>
    </contents>
    <universal-time>
      <integer>3417747266</integer>
    </universal-time>
    <channel>
      <string>#lispcafe</string>
    </channel>
    <colorization-mode>
      <string></string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <null/>
    </is-unicode>
  </annotation>
  <annotation>
    <number>
      <integer>4</integer>
    </number>
    <user>
      <string>jdrake</string>
    </user>
    <title>
      <string>Complete Code</string>
    </title>
    <contents>
      <string>(define (within? x lower upper)
  (and (&lt;= x upper) (&gt;= x lower)))

(define (wrap-range x lower upper)
  (cond
    ((&gt; x upper) (wrap-range (+ lower (- x upper)) lower upper))
    ((&lt; x lower) (wrap-range (- upper (- lower x)) lower upper))
    (else x))) 

; rotate-char char amount lower upper -&gt; char
; If char is within lower and upper range, increase char by amount, and if
; it goes over the upper range, then wrap around to the lower range.
(define (rotate-char in amount lower upper)
  (let
      ((in (char-&gt;integer in))
       (lower (char-&gt;integer lower))
       (upper (char-&gt;integer upper)))
    (integer-&gt;char
     (if (within? in lower upper) 
         (wrap-range (+ in amount) lower upper)
         in))))


(define (rot13 in)
  (cond 
      ((char-lower-case? in) (rotate-char in 13 #\a #\z))
      ((char-upper-case? in) (rotate-char in 13 #\A #\Z))
      (else in)))


; I am not sure I want to think about this for now...
;(define (rotate-char2 in amount lower upper)
;  (let loop ((i in)) 
;    (cond 
;      ((&lt; i lower) (loop (+ i amount)))
;      ((&lt; i upper) i)
;      (else (loop (+ lower (- i upper)))))))
</string>
    </contents>
    <universal-time>
      <integer>3417745436</integer>
    </universal-time>
    <channel>
      <string>#lispcafe</string>
    </channel>
    <colorization-mode>
      <string></string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <null/>
    </is-unicode>
  </annotation>
  <annotation>
    <number>
      <integer>3</integer>
    </number>
    <user>
      <string>jdrake</string>
    </user>
    <title>
      <string>updated rotate-char</string>
    </title>
    <contents>
      <string>(define (rotate-char in amount lower upper)
  (let
      ((in (char-&gt;integer in))
       (lower (char-&gt;integer lower))
       (upper (char-&gt;integer upper)))
    (integer-&gt;char
     (if (within? in lower upper) 
         (begin
           (set! in (+ in amount))
           (wrap-range in lower upper)
         in)))))</string>
    </contents>
    <universal-time>
      <integer>3417745035</integer>
    </universal-time>
    <channel>
      <string>#lispcafe</string>
    </channel>
    <colorization-mode>
      <string></string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <null/>
    </is-unicode>
  </annotation>
  <annotation>
    <number>
      <integer>2</integer>
    </number>
    <user>
      <string>jdrake</string>
    </user>
    <title>
      <string>New version</string>
    </title>
    <contents>
      <string>(define (wrap-range x lower upper)
  (cond
    ((&gt; x upper) (wrap-range (+ lower (- x upper)) lower upper))
    ((&lt; x lower) (wrap-range (- upper (- lower x)) lower upper))
    (else x))) </string>
    </contents>
    <universal-time>
      <integer>3417744710</integer>
    </universal-time>
    <channel>
      <string>#lispcafe</string>
    </channel>
    <colorization-mode>
      <string></string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <null/>
    </is-unicode>
  </annotation>
  <annotation>
    <number>
      <integer>1</integer>
    </number>
    <user>
      <string>jdrake</string>
    </user>
    <title>
      <string>Recurse no worky</string>
    </title>
    <contents>
      <string>(define (wrap-range x lower upper)
  (let loop ('())
  (cond
    ((&gt; x upper) (loop (+ lower (- x upper))))
    ((&lt; x lower) (loop (- upper (- lower x))))
    (else x)))) 
</string>
    </contents>
    <universal-time>
      <integer>3417744443</integer>
    </universal-time>
    <channel>
      <string>#lispcafe</string>
    </channel>
    <colorization-mode>
      <string></string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <null/>
    </is-unicode>
  </annotation>
</paste-with-annotations>