Created
November 24, 2011 20:08
-
-
Save glejeune/1392183 to your computer and use it in GitHub Desktop.
My second FooBarQix (http://www.code-story.net/2011/11/16/foobarqix.html) solution
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
| (setq *fbq* (make-hash-table)) | |
| (setf (gethash 3 *fbq*) "Foo") | |
| (setf (gethash 5 *fbq*) "Bar") | |
| (setf (gethash 7 *fbq*) "Qix") | |
| (defun foo (v) ( | |
| let ((div "")) | |
| (maphash #'(lambda (key value) | |
| (cond ((= (mod v key) 0) | |
| (setf div (concatenate 'string value div)) | |
| )) | |
| ) | |
| *fbq*) | |
| div | |
| )) | |
| (defun bar (v) ( | |
| let ((rep "")) | |
| (map 'string #'(lambda (c) | |
| (setf k (gethash (parse-integer (string c)) *fbq*)) | |
| (if (not (null k)) | |
| (setf rep (concatenate 'string rep k)) | |
| ) | |
| c | |
| ) | |
| (write-to-string v)) | |
| rep | |
| )) | |
| (defun qix (v) ( | |
| let ((result (concatenate 'string (foo v) (bar v)))) | |
| (if (= 0 (length result)) | |
| (setf result (write-to-string v)) | |
| ) | |
| result | |
| )) | |
| (loop for i from 1 to 100 do (format t "~D : ~A~%" i (qix i))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment