From 3062b939f20b857f13e282fe143290033d1e7958 Mon Sep 17 00:00:00 2001 From: "Samuel W. Flint" Date: Sun, 23 Oct 2016 11:20:44 -0500 Subject: [PATCH] Brought in aget and ensure-list because informatimago is no longer in quicklisp --- larcs.org | 68 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 60 insertions(+), 8 deletions(-) diff --git a/larcs.org b/larcs.org index 22b85cb41c5ddeec3b0de88a99ff0a86b4543eb1..fc1ca173d511ce541ff0cf343ec5c3cf19166889 100644 --- a/larcs.org +++ b/larcs.org @@ -85,7 +85,7 @@ The CAS contained in this is called LARCS, or the Lisp Automated Rewrite and Cal #+TOC: headlines 3 #+TOC: listings -* DONE Common Functionality [3/3] +* WORKING Common Functionality [3/5] :PROPERTIES: :CREATED: <2016-06-11 Sat 22:23> :ID: f153a0fe-ec04-47b1-bdc5-290cc62bc985 @@ -173,6 +173,58 @@ This is a mapping between the names of constants and the way that they are corre (mapcar #'export *constant-names*) #+END_SRC +** TODO Aget +:PROPERTIES: +:CREATED: <2016-10-23 Sun 11:14> +:END: + +#+Caption: Aget +#+Name: common-aget +#+BEGIN_SRC lisp + (defun aget (place indicator &optional default) + " + RETURN: The value of the entry INDICATOR of the a-list PLACE, or DEFAULT. + " + (let ((a (assoc indicator place))) + (if a (cdr a) default))) + + (define-setf-expander aget (place indicator &optional default &environment env) + (declare (ignore default)) + (multiple-value-bind (vars vals store-vars writer-form reader-form) + (get-setf-expansion place env) + (let* ((vindicator (gensym "INDICATOR")) + (vvalue (gensym "VALUE")) + (vstore (first store-vars)) + (acs (gensym "PAIR"))) + (values (list* vindicator vars) + (list* indicator vals) + (list vvalue) + `(let* ((,acs (assoc ,vindicator ,reader-form))) + (if ,acs + (setf (cdr ,acs) ,vvalue) + (let ((,vstore (acons ,vindicator ,vvalue ,reader-form))) + ,writer-form)) + ,vvalue) + `(assoc ,vindicator ,reader-form))))) +#+END_SRC + +** TODO Ensure List +:PROPERTIES: +:CREATED: <2016-10-23 Sun 11:17> +:ID: 08d8e031-a30f-41b6-9981-caec2f07f2a0 +:END: + +#+Caption: Ensure List +#+Name: ensure-list +#+BEGIN_SRC lisp + (defun ensure-list (object) + " + RETURN: If OBJECT is a list then OBJECT, otherwise a fresh + list containing OBJECT. + " + (if (listp object) object (list object))) +#+END_SRC + ** DONE Assembly CLOSED: [2016-07-30 Sat 15:43] :PROPERTIES: @@ -190,6 +242,10 @@ This is where the common functions and constants are assembled into their own pa <> <> + + <> + + <> #+END_SRC * DONE Expression Typing [8/8] @@ -2379,7 +2435,9 @@ This defines the common package, which keeps a few macros and variables that are #:symbolicate) (:export #:gen-args-list #:*special-symbols-to-sequences* - #:*constant-names*) + #:*constant-names* + #:aget + #:ensure-list) (:nicknames #:common)) #+END_SRC @@ -2478,9 +2536,6 @@ This is a rather simple package, providing a way to differentiate equations for #:larcs.polynomials) (:import-from #:alexandria #:symbolicate) - (:import-from #:com.informatimago.common-lisp.cesarum.list - #:aget - #:ensure-list) (:export :differentiate) (:nicknames :diff)) #+END_SRC @@ -2505,9 +2560,6 @@ Again, this is a relatively simple package definition, providing a way to conver #:larcs.polynomials) (:import-from #:alexandria #:symbolicate) - (:import-from #:com.informatimago.common-lisp.cesarum.list - #:aget - #:ensure-list) (:export #:convert-for-display) (:nicknames #:typeset)) #+END_SRC