common lisp 笔记2 a cd ripper
1,定义和获取列表元素
(list 1 2 3)
(list :a 1 :b 3 :c 2)
(getf (list :a 1 :b 3) :b); output:3
2,定义简单的函数
(defun make-cd (title artist rating ripped)
(list :title title :artist artist :rating rating :ripped ripped))
3,定义全局变量
(devar *db* nil)
4,向全局变量添加纪录
(defun add-record (cd)
(push cd *db*))
(add-record (make-cd "night" "chopin" 7 t))
5,循环输出列表
(defun dump-db () (dolist (cd *db*) (format t "~{~a: ~10t~a~%~}~%" cd)))
~a 消耗一个实参并美化出来 ~t 产生制表符 ~{和~}之间对列表循环操作 ~% 换行
6,待续~