Created
May 29, 2013 09:52
-
-
Save thinkphp/5669206 to your computer and use it in GitHub Desktop.
Converts a decimal to binar 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
| ;Adrian Statescu <mergesortv@gmail.com> | |
| ;converts a decimal to binar | |
| (defun toBin(N) | |
| + | |
| + (let ((R)) | |
| + | |
| + (dotimes (i 15 R) | |
| + | |
| + (setf bit (logand (ash N (- i)) 1)) | |
| + | |
| + (setf R (cons bit R)) | |
| + ) | |
| + ) | |
| +) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment