All pastes #2093476 Raw Edit

Someone

public text v1 · immutable
#2093476 ·published 2011-11-10 03:52 UTC
rendered paste body
(define (displist origlist)
    (define (indent-helper n)
        (cond
            ((> n 0)
                (display "    ")
                (indent-helper (- n 1)))
            (else
                (display ""))))
    (define (dspl-help templist depth bracketed? amicdr?)
        (cond
            ((null? templist)
                (indent-helper depth)
                (display ")")(newline))
            ((pair? templist)
                (cond 
                    ((not bracketed?)
                        (indent-helper depth)
                        (display "(")(newline)
                        (dspl-help (car templist) (+ depth 1) #f #f)
                        (dspl-help (cdr templist) depth #t #t))
                    (else
                        (dspl-help (car templist) (+ depth 1) #f #f)
                        (dspl-help (cdr templist) depth #f #t))))
            (else
                (cond
                    (amicdr?
                        (indent-helper (+ depth 1))
                        (display ".")(newline)
                        (dspl-help (list templist) depth bracketed? #f))
                    (else
                        (indent-helper depth)
                        (display templist)(newline))))))
    (dspl-help origlist 0 #f #f))