Skip to content

Instantly share code, notes, and snippets.

@orleika
Created April 29, 2016 00:32
Show Gist options
  • Save orleika/e6f8c8cdf6f64a8168714c3ddd2f340c to your computer and use it in GitHub Desktop.
Save orleika/e6f8c8cdf6f64a8168714c3ddd2f340c to your computer and use it in GitHub Desktop.
(define (atom? x)
(and (not (null? x))
(not (pair? x))))
(define (append a b)
(cond ((null? a) b)
(else (cons (car a) (append (cdr a) b)))))
(define (linearize x)
(cond ((null? x) '())
((atom? x) x)
((atom? (car x)) (cons (car x) (linearize (cdr x))))
(else (append (linearize (car x)) (linearize (cdr x))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment