[ create a new paste ] login | about

Link: http://codepad.org/5mdIPU3e    [ raw code | output | fork ]

programmingpraxis - Scheme, pasted on Sep 29:
1
2
3
4
5
6
7
8
9
10
11
; thue-morse sequence

(define (complement digits)
  (map (lambda (d) (if (zero? d) 1 0)) digits))

(define (thue-morse n)
  (let loop ((tms '(0)) (n n))
    (if (zero? n) tms
      (loop (append tms (complement tms)) (- n 1)))))

(display (thue-morse 6))


Output:
1
(0 1 1 0 1 0 0 1 1 0 0 1 0 1 1 0 1 0 0 1 0 1 1 0 0 1 1 0 1 0 0 1 1 0 0 1 0 1 1 0 0 1 1 0 1 0 0 1 0 1 1 0 1 0 0 1 1 0 0 1 0 1 1 0)


Create a new paste based on this one


Comments: