Last active
November 8, 2016 03:53
-
-
Save pieman2201/2a9b0c9f51a7499cf0560953155a0b2e to your computer and use it in GitHub Desktop.
really awful thue-morse generator in common lisp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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