Last active
August 29, 2015 13:55
-
-
Save meki/8783957 to your computer and use it in GitHub Desktop.
AOJ_0001_Common 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
;; 標準入力から n 回受け取ってリストに追加 | |
(defun input (lst n) | |
(cond | |
((eq (length lst) n) | |
lst | |
) | |
(t | |
(input (append lst (list (read)) ) n ) | |
) | |
) | |
) | |
;; リストの先頭 n 要素の部分配列を作成 | |
(defun gettop (lst n) | |
(if (or (= n 0) (null lst)) | |
nil | |
(cons (car lst) | |
(gettop (cdr lst) (- n 1)) | |
) | |
) | |
) | |
(mapcar #'(lambda (x) (format t "~A~%" x)) ; リストの要素を改行区切りで出力する | |
(gettop | |
(sort (input () 10) #'>) ; 標準入力からリストを作り降順ソートする | |
3 ; 先頭3つのリストを作成 | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment