cl

CommonLisp testbed
git clone git://git.janpasierb.com/cl.git
Log | Files | Refs

commit 1b4ea4f522287dcdd8a3a09c97d2dded83906975
Author: Jan P. Pasierb <me@janpasierb.com>
Date:   Mon,  2 Jun 2025 21:54:02 +0100

Initialising CommonLisp testbed project, including: SLIMV command list, mp3 test file, test db and some random test files

Diffstat:
A.gitignore | 1+
Afoo.fasl | 0
Afoo.lisp | 14++++++++++++++
Akeylist | 26++++++++++++++++++++++++++
Amp3.fasl | 0
Amp3.lisp | 65+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amy-cds.db | 3+++
7 files changed, 109 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1 @@ +*.swp diff --git a/foo.fasl b/foo.fasl Binary files differ. diff --git a/foo.lisp b/foo.lisp @@ -0,0 +1,14 @@ +(defun square (x) + (* x x)) + +(defun square-of-sum (x y) + (square (+ x y))) + +(defun sum-of-squares (x y) + (+ (square x) (square y))) + +(square-of-sum 2 3) +(sum-of-squares 2 3) + +(defun hello-world () + (format t "Hello, world!")) diff --git a/keylist b/keylist @@ -0,0 +1,26 @@ +,c - connect to swank server +,b - evaluate buffer +,d - evaluate top-level form +,e - evaluate expression under cursor +,D - compile function under cursor +,F - compile file +,L - compile & load file +,s - describe symbol +,xl - list callers +,i - inspect variable +,q - quit inspector +,a - abort and quit debugger to previous level +,q - abort and quit debugger to top level +,t - toggle tracing +,1 - expand macro form once +,m - expand macro fully +,h - invoke help + +S-expressions: +,W - wrap +,S - splice (remove outer pair of parens) +,O - split +,J - join +,I - raise subform +,> - slurp next expression +,< - barf inner expression diff --git a/mp3.fasl b/mp3.fasl Binary files differ. diff --git a/mp3.lisp b/mp3.lisp @@ -0,0 +1,65 @@ +(defvar *db* nil) + +(defun make-cd (title artist rating ripped) + (list :title title :artist artist :rating rating :ripped ripped)) + +(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 "Ripped [y/n]: "))) + +(defun add-cds () + (loop (add-record (prompt-for-cd)) + (if (not (y-or-n-p "Another? [y/n]: ")) (return)))) + +(defun save-db (filename) + (with-open-file (out filename + :direction :output + :if-exists :supersede) + (with-standard-io-syntax + (print *db* out)))) + +(defun load-db (filename) + (with-open-file (in filename) + (with-standard-io-syntax + (setf *db* (read in))))) + +(defun select (selector-fn) + (remove-if-not selector-fn *db*)) + +(defun where (&key title artist rating (ripped nil ripped-p)) + #'(lambda (cd) + (and + (if title (equal (getf cd :title) title) t) + (if artist (equal (getf cd :artist) artist) t) + (if rating (equal (getf cd :rating) rating) t) + (if ripped-p (equal (getf cd :ripped) ripped) t)))) + +(defun update (selector-fn &key title artist rating (ripped nil ripped-p)) + (setf *db* + (mapcar + #'(lambda (row) + (when (funcall selector-fn row) + (if title (setf (getf row :title) title)) + (if artist (setf (getf row :artist) artist)) + (if rating (setf (getf row :rating) rating)) + (if ripped-p (setf (getf row :ripped) ripped))) + row) *db*))) + +(defun delete-rows (selector-fn) + (setf *db* (remove-if selector-fn *db*))) + diff --git a/my-cds.db b/my-cds.db @@ -0,0 +1,2 @@ + +((:TITLE "In Silico" :ARTIST "Pendulum" :RATING 6 :RIPPED NIL) (:TITLE "I Am the Night" :ARTIST "Perturbator" :RATING 5 :RIPPED NIL) (:TITLE "Hold Your Colour" :ARTIST "Pendulum" :RATING 10 :RIPPED T) (:TITLE "Szczerzenie" :ARTIST "Kly" :RATING 9 :RIPPED T) (:TITLE "Fallen" :ARTIST "Evanescence" :RATING 7 :RIPPED NIL)) + \ No newline at end of file