Plaster
New
List
Login
text
default
anonymous
2024.01.20 01:50:31
(defmacro with-interpolated-symbols (bindings &body body) `(let (,@(loop for (var template) in bindings collect `(,var (intern (interpolate ,template))))) ,@body)) (macrolet ((defmethods (dim spacedim) (with-interpolated-symbols ((%triangulation '#:triangulation-$dim-$spacedim) (make-triangulation '#:make-triangulation-$dim-$spacedim) (%make-triangulation '#:%make-triangulation-$dim-$spacedim) (%n-cells '#:n-cells<triangulation-$dim-$spacedim>) (%hyper-cube '#:hyper-cube<triangulation-$dim-$spacedim>) (%hyper-shell '#:hyper-shell<triangulation-$dim-$spacedim>)) `(progn ;; TODO Try passing check as whatever non-NIL. (defun ,make-triangulation (&key smoothing check-for-distorted-cells) (,%make-triangulation smoothing check-for-distorted-cells)) (defmethod n-cells ((tria ,%triangulation)) (,%n-cells tria)) (defmethod print-object ((tria ,%triangulation) stream) (print-unreadable-object (tria stream :type t) (format stream "~@<~A cells~:@>" (,%n-cells tria)))) (defmethod make-hyper-cube ((tria ,%triangulation) &key (left 0d0) (right 1d0) colorize) (,%hyper-cube tria left right colorize) tria) ,@(when (= dim spacedim) `((defmethod make-hyper-shell ((tria ,%triangulation) &key center inner-radius outer-radius (n-cells 0) colorize) (,%hyper-shell tria center inner-radius outer-radius n-cells colorize) tria))))))) (defmethods 2 2) (defmethods 2 3) (defmethods 3 3))
Raw
Annotate
Repaste
Edit