src/utils.lisp @ 01019d2d2be8

Add scratch.lisp to .hgignore.
author Steve Losh <steve@stevelosh.com>
date Fri, 22 Apr 2016 23:12:34 +0000
parents 2278039315fa
children 69f98eb3a1df
(in-package #:coding-math.utils)

(defun dividesp (n divisor)
  "Return whether `n` is evenly divisible by `divisor`."
  (zerop (mod n divisor)))


(defmacro mulf (place n &environment env)
  "Multiply `place` by `n` in-place."
  (multiple-value-bind (temps exprs stores store-expr access-expr)
      (get-setf-expansion place env)
    `(let* (,@(mapcar #'list temps exprs)
            (,(car stores) (* ,n ,access-expr)))
       ,store-expr)))

(defun a (alist key) ; lol
  (cdr (assoc key alist)))

(defmacro in-context (&body body)
  `(prog1
    (push-matrix)
    (progn ,@body)
    (pop-matrix)))