Commit 579cf96b authored by Liam M. Healy's avatar Liam M. Healy
Browse files

Move definitions between systems

Move some definitions of print-grid-readably to grid from
foreign-array, because physical-dimension relies on this function
being defined. Remove the (T T) method left in the defgeneric for /i.
parent f0472919
;; Foreign (C or C-compatible) arrays
;; Liam Healy 2008-12-28 10:44:22EST foreign-array.lisp
;; Time-stamp: <2013-11-23 09:45:23EST foreign-array.lisp>
;; Time-stamp: <2013-11-27 10:44:57EST foreign-array.lisp>
;;
;; Copyright 2008, 2009, 2010, 2011, 2012, 2013 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -152,21 +152,10 @@
(defparameter *print-foreign-array-readably* t
"Print the contents of the foreign-array with the #m reader macro.")
;;;; Move these
(defgeneric print-grid-readably (object contents-writer stream)
(:documentation "Print the grid readably. The contents-writer is a function that is called on the stream and writes the contents of the grid.")
(:method ((object t) contents-writer stream)
(declare (ignore object))
(funcall contents-writer stream)))
(defmethod print-grid-readably ((object foreign-array) contents-writer stream)
(format stream "#~@[~d~]m" (hashm-numeric-code (element-type object)))
(funcall contents-writer stream))
(defmethod print-grid-readably ((object array) contents-writer stream)
(format stream (if (= (length (dimensions object)) 2) "#2A" "#"))
(funcall contents-writer stream))
(defmethod print-object ((object foreign-array) stream)
(if (and *print-foreign-array-readably* *print-contents*)
(antik::cl-readable-nf (antik::nf-grid object stream))
......
;; Test grids
;; Liam Healy 2009-11-28 09:47:35EST grids.lisp
;; Time-stamp: <2010-07-03 22:55:04EDT grids.lisp>
;; Time-stamp: <2013-11-27 10:51:06EST grids.lisp>
;;
;; Copyright 2009 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -24,8 +24,8 @@
"Element will be computed from the indices by multiplying
by powers of 10 and summing."
(loop with dims = (length args)
for i below dims
sum (* (expt 10 (- dims 1 i)) (nth i args))))
for i from 0 below dims
sum (* (expt 10 (- dims 1 i)) (the number (elt args i)))))
(defun offset-ifd (offset)
(lambda (&rest args) (+ offset (apply 'index-fill-decadal args))))
......
;; Utility
;; Liam Healy 2009-11-28 22:44:13EST util.lisp
;; Time-stamp: <2011-04-09 20:31:23EDT util.lisp>
;; Time-stamp: <2013-11-27 10:45:03EST util.lisp>
;;
;; Copyright 2009, 2010 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -96,3 +96,19 @@
value)
(coerce value type)))
value))
;;;;****************************************************************************
;;;; Readable output
;;;;****************************************************************************
(defgeneric print-grid-readably (object contents-writer stream)
(:documentation "Print the grid readably. The contents-writer is a function that is called on the stream and writes the contents of the grid.")
(:method ((object t) contents-writer stream)
(declare (ignore object))
(funcall contents-writer stream)))
(defmethod print-grid-readably ((object array) contents-writer stream)
(format stream (if (= (length (dimensions object)) 2) "#2A" "#"))
(funcall contents-writer stream))
;; Generic functions for generalized numbers
;; Liam Healy Tue Feb 9 1999 - 21:38
;; Time-stamp: <2013-11-23 12:13:32EST generic.lisp>
;; Time-stamp: <2013-11-27 10:36:44EST generic.lisp>
;; Copyright 2011, 2013 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -125,7 +125,6 @@
;; For each generalized number, one of these must be specified
;; as a specialized method.
;; see below for reciprocal (:method (a (b null)) (/i 1 a))
(:method (a b) (*i a (/ b)))
;; Two sequences
(:method ((a sequence) (b sequence))
(progn
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment