프로그래밍/Common Lisp
스트링 배열 정렬(sorting)하기 with Common Lisp
Scripter
2013. 9. 6. 23:18
[파일명: testSort.lsp]------------------------------------------------
(defun printArray(a)
(format t "[")
(loop for i from 0 below (1- (length a)) do
(format t "~A, " (nth i a))
)
(if (plusp (length a))
(format t "~A" (nth (1- (length a)) a))
)
(format t "]~%")
)
(setf list ext:*args*)
(sort list #'string<)
(printArray list)
------------------------------------------------
실행> clisp testSort.lsp one two three four five
[five, four, one, three, two]
실행> clisp testSort.lsp 하나 둘 셋 넷 다섯
[넷, 다섯, 둘, 셋, 하나]