Skip to content

Instantly share code, notes, and snippets.

@pieman2201
Last active November 8, 2016 03:53
Show Gist options
  • Select an option

  • Save pieman2201/2a9b0c9f51a7499cf0560953155a0b2e to your computer and use it in GitHub Desktop.

Select an option

Save pieman2201/2a9b0c9f51a7499cf0560953155a0b2e to your computer and use it in GitHub Desktop.
really awful thue-morse generator in common lisp
(defun tm-compute (loops)
(let ((current 1) (ones 0) (complement 0))
(dotimes (loop loops)
(setf ones (- (expt 2 (- (length (format nil "0~B" current)) 0)) 1))
(setf complement (- ones current))
(setf current (parse-integer (format nil "~B~B" current complement) :radix 2)))
(format t "0~B" current)))
; call with:
; (tm-compute number-of-loops-to-do)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment