Created
February 2, 2019 23:34
-
-
Save imjacobclark/60676099ed8d17169b3df6e3911b2d51 to your computer and use it in GitHub Desktop.
Number padder in Lisp
This file contains 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
(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) ) | |
(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