2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
8
Task/Nth/Common-Lisp/nth-1.lisp
Normal file
8
Task/Nth/Common-Lisp/nth-1.lisp
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
(defun add-suffix (number)
|
||||
(let* ((suffixes #10("th" "st" "nd" "rd" "th"))
|
||||
(last2 (mod number 100))
|
||||
(last-digit (mod number 10))
|
||||
(suffix (if (< 10 last2 20)
|
||||
"th"
|
||||
(svref suffixes last-digit))))
|
||||
(format nil "~a~a" number suffix)))
|
||||
2
Task/Nth/Common-Lisp/nth-2.lisp
Normal file
2
Task/Nth/Common-Lisp/nth-2.lisp
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(defun add-suffix (n)
|
||||
(format nil "~d'~:[~[th~;st~;nd~;rd~:;th~]~;th~]" n (< (mod (- n 10) 100) 10) (mod n 10)))
|
||||
6
Task/Nth/Common-Lisp/nth-3.lisp
Normal file
6
Task/Nth/Common-Lisp/nth-3.lisp
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
(loop for (low high) in '((0 25) (250 265) (1000 1025))
|
||||
do (progn
|
||||
(format t "~a to ~a: " low high)
|
||||
(loop for n from low to high
|
||||
do (format t "~a " (add-suffix n))
|
||||
finally (terpri))))
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
(defun add-suffix (number)
|
||||
(let* ((suffixes #10("th" "st" "nd" "rd" "th"))
|
||||
(last2 (mod number 100))
|
||||
(last-digit (mod number 10))
|
||||
(suffix (if (< 10 last2 20)
|
||||
"th"
|
||||
(svref suffixes last-digit))))
|
||||
(format nil "~a~a" number suffix)))
|
||||
|
||||
|
||||
(defun add-suffix (n)
|
||||
"A more concise, albeit less readable version"
|
||||
(format nil "~d'~:[~[th~;st~;nd~;rd~:;th~]~;th~]" n (< (mod (- n 10) 100) 10) (mod n 10)))
|
||||
|
||||
|
||||
(loop for (low high) in '((0 25) (250 265) (1000 1025))
|
||||
do (progn
|
||||
(format t "~a to ~a: " low high)
|
||||
(loop for n from low to high
|
||||
do (format t "~a " (add-suffix n))
|
||||
finally (terpri))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue