fork download
  1. (define (get) (get1 (quote ()) (read)))(define (get1 b r) (if (eof-object? r) (reverse b) (get1 (cons r b) (read))))(define (put) (put1 (quote ()) (read-char)))(define (put1 b r) (if (eof-object? r) (list->string (reverse b)) (if (char=? #\) r) (put1 (cons #\. (cons #\. (cons r b))) (read-char)) (put1 (cons r b) (read-char)))))(define (final lis) (if (null? lis) lis (final1 (car lis) (cdr lis))))(define (final1 f r) (if (and (pair? f) (pair? (cdr f)) (eqv? (quote quote) (car f))) (cons f (final (cdr r))) (if (list? f) (final2 f (gather (count (car r)) (cons (quote ()) (final (cdr r))))) (if (or (vector? f) (pair? f) (eq? #\) f)) (cons f (final (cdr r))) (cons f (final r))))))(define (final2 f g) (cons (append (final f) (car g)) (cdr g)))(define (count s) (- (string-length (symbol->string s)) 2))(define (gather c lis) (if (= c 0) (cons (reverse (car lis)) (cdr lis)) (gather (- c 1) (cons (cons (cadr lis) (car lis)) (cddr lis)))))(for-each write (final (with-input-from-string (put) get)))
Success #stdin #stdout 0s 50224KB
stdin
(define)... (longer x y)
(define).. (compare x y)
(and).. (pair? x)
(or).. (not y)
(compare).. (cdr x) (cdr y)
(if)... (and).. (list? x) (list? y)
(compare x y)
(> (length x) (length y))
stdout
(define (longer x y) (define (compare x y) (and (pair? x) (or (not y) (compare (cdr x) (cdr y))))) (if (and (list? x) (list? y)) (compare x y) (> (length x) (length y))))