Skip to content

Instantly share code, notes, and snippets.

@glejeune
Created November 24, 2011 20:08
Show Gist options
  • Select an option

  • Save glejeune/1392183 to your computer and use it in GitHub Desktop.

Select an option

Save glejeune/1392183 to your computer and use it in GitHub Desktop.
(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