fork download
  1. ; find the difference
  2.  
  3. (define (sum xs) (apply + xs))
  4.  
  5. (define (diff1 xstr ystr)
  6. (let loop ((xs (sort (string->list xstr) char<?))
  7. (ys (sort (string->list ystr) char<?)))
  8. (cond ((null? xs) (car ys))
  9. ((char=? (car xs) (car ys))
  10. (loop (cdr xs) (cdr ys)))
  11. (else (car ys)))))
  12.  
  13. (display (diff1 "abcdef" "bfxdeac")) (newline)
  14.  
  15. (define (diff2 xstr ystr)
  16. (let ((x (sum (map char->integer (string->list xstr))))
  17. (y (sum (map char->integer (string->list ystr)))))
  18. (integer->char (- y x))))
  19.  
  20. (display (diff2 "abcdef" "bfxdeac")) (newline)
Success #stdin #stdout 0s 50288KB
stdin
Standard input is empty
stdout
x
x