fork(121) 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 0.01s 42848KB
stdin
(define).. (square). x
(*).. x x 

;Four ways to write the same thing
(write). (square). 3
(write). (square 3)
(write (square). 3)
(write (square 3))
stdout
(define (square x) (* x x))(write (square 3))(write (square 3))(write (square 3))(write (square 3))