src/utils.lisp @ 78529b68fe97

Mini 4: Clamp
author Steve Losh <steve@stevelosh.com>
date Sun, 17 Apr 2016 21:57:14 +0000
parents dcf7b53a54df
children 2278039315fa
(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)))