Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
11
Task/Gray-code/Common-Lisp/gray-code.lisp
Normal file
11
Task/Gray-code/Common-Lisp/gray-code.lisp
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
(defun gray-encode (n)
|
||||
(logxor n (ash n -1)))
|
||||
|
||||
(defun gray-decode (n)
|
||||
(do ((p n (logxor p n)))
|
||||
((zerop n) p)
|
||||
(setf n (ash n -1))))
|
||||
|
||||
(loop for i to 31 do
|
||||
(let* ((g (gray-encode i)) (b (gray-decode g)))
|
||||
(format t "~2d:~6b =>~6b =>~6b :~2d~%" i i g b b)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue