#!/usr/local/bin/sbcl --script (format t "~a~%"(remove-if-not #'evenp '(1 2 3 4 5 6 7 8 9 10))) (remove-if-not #'evenp '(1 2 3 4 5 6 7 8 9 10)) (format t "~a~%" (remove-if-not #'(lambda (x) (= 0 (mod x 2))) '(1 2 3 4 5 6 7 8 9 10))) (format t "~a~%" (remove-if-not #'(lambda (x) (= 1 (mod x 2))) '(1 2 3 4 5 6 7 8 9 10))) (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*)) (add-record (make-cd "Roses" "Kathy Mattea" 7 t)) (add-record (make-cd "Fly" "Dixie Chicks" 8 t)) (add-record (make-cd "Home" "Dixie Chicks" 9 t)) (defun dump-db () (dolist (cd *db*) (format t "~{~a:~10t~a~%~}~%" cd))) (dump-db) (defun select-by-artist (artist) (remove-if-not #'(lambda (cd) (equal (getf cd :artist) artist)) *db*)) (defun select (selector-fn) (remove-if-not selector-fn *db*)) (defun artist-selector (artist) #'(lambda (cd) (equal (getf cd :artist) artist))) (format t "~a~%" (select (artist-selector "Dixie Chicks")))