Recently Written · git

common-lisp-utils

My utilities for Common Lisp programming.

git clone https://github.com/equwal/common-lisp-utils

Log | Files | Refs


commit 085cbe08c3b02f817819267644494ff5fced224d
Spenser Truex <spensertruexonline@gmail.com>
2018-04-20 15:11:25 -0300

Export it anaphor.

 .gitignore | 18 +-----------------
 utils.lisp | 37 +++++++++++++++++++++++++++++++++++--
 2 files changed, 36 insertions(+), 19 deletions(-)
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index e7de127..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,17 +0,0 @@
-*.FASL
-*.fasl
-*.lisp-temp
-*.dfsl
-*.pfsl
-*.d64fsl
-*.p64fsl
-*.lx64fsl
-*.lx32fsl
-*.dx64fsl
-*.dx32fsl
-*.fx64fsl
-*.fx32fsl
-*.sx64fsl
-*.sx32fsl
-*.wx64fsl
-*.wx32fsl
diff --git a/.gitignore b/.gitignore
new file mode 120000
index 0000000..758b41b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/home/john/common-lisp/.gitignore
\ No newline at end of file
diff --git a/utils.lisp b/utils.lisp
index c462595..c04460a 100644
--- a/utils.lisp
+++ b/utils.lisp
@@ -4,8 +4,10 @@
   (:export :make-read
 	   :once-only
 	   :with-gensyms
-	   :y-comb
-	   :aif))
+	   :y
+	   :aif
+	   :it ;; A feature of any anamorphic macro here.
+	   ))
 (in-package :utils)
 (defun y-comb (f)
   "The Y-combinator from the Lambda calculus of Alonzo Church."
@@ -91,3 +93,34 @@ This is a token reader with character predicates."
      (if it
 	 ,then
 	 ,else)))
+;; For making a matrix, reading it, and getting its dimensions
+;; Arrays don't support O(1) dimension reading support.
+(defclass matrix () ((dimensions :accessor dim
+				 :initarg :dim)
+		     (array :accessor ar
+			    :initarg :ar)))
+
+(defmacro mref (matrix dimensions)
+  `(aref (ar ,matrix) ,dimensions))
+(defun group (list size)
+  (labels ((recur (old-list new-list size-count this-node)
+	     (cond ((null old-list) (reverse new-list))
+		   ((= 1 size-count) (recur (cdr old-list)
+					    (cons (reverse (cons (car old-list)
+								 this-node))
+						  new-list)
+					    size
+					    nil))
+		   (t (recur (cdr old-list)
+			     new-list
+			     (1- size-count)
+			     (cons (car old-list) this-node))))))
+    (recur list nil size nil)))
+(defmacro abbrev (short long)
+  `(defmacro ,short (&rest args)
+     `(,',long ,@args)))
+(defmacro abbrevs (&rest names)
+  `(progn
+     ,@(mapcar #'(lambda (pair)
+		   `(abbrev ,@pair))
+	       (group names 2))))