Red Baron

SEARCH RESAULT : 글 검색 결과 - LISP STUDY (총 1개)

POST : Program

lisp study1

(defun make-cd (title artist rating ripped)
  (list :title title :artist artist :rating rating :ripped ripped))

(defvar *db* nil)

(defun add-record (cd) (push cd *db*))

(defun dump-db ()
  (dolist (cd *db*)
  (format t "~{~a:~10t~a~%~}~%" cd)))

(defun prompt-read (prompt)
  (format *query-io* "~a: " prompt)
  (force-output *query-io*)
  (read-line *query-io*))

(defun prompt-for-cd()
  (make-cd
  (prompt-read "Title")
  (prompt-read "Artist")
  (or (parse-integer (prompt-read "Rating") :junk-allowed t) 0)
  (y-or-n-p (prompt-read "Ripped [y/n]:"))))

(defun add-cds()
  (loop (add-record (prompt-for-cd))
(if (not (y-or-n-p "Another? [y/n]: ")) (return))))


-. list --> macro for list strucrure

-. (list :title title :artist artis)
   :<- make index for data

-. ~is likely % from printf in C
-. or make not null to input data that is null ,and make default value of 0
-. y-or-n-p make constraint to input y or n (common lisp function)


top

posted at

2006. 12. 10. 22:37


CONTENTS

Red Baron
BLOG main image

RSS 2.0Tattertools
공지 아카이브
최근 글 최근 댓글 최근 트랙백
카테고리 태그 구름사이트 링크