Skip to content

Instantly share code, notes, and snippets.

@imjacobclark
Created February 2, 2019 23:34
Show Gist options
  • Save imjacobclark/60676099ed8d17169b3df6e3911b2d51 to your computer and use it in GitHub Desktop.
Save imjacobclark/60676099ed8d17169b3df6e3911b2d51 to your computer and use it in GitHub Desktop.
Number padder in Lisp
(defun pad(num)
(concatenate 'string "0" num))
(defun should-pad(num)
(= (length num) 1))
(defun apply-padding(num)
(cond
((should-pad num) (pad num))
(t num)))
(defun pad-list(nums)
(mapcar #'apply-padding nums) )
(print
(pad-list
(list "1" "19" "2" "3" "55" "4" "12")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment