# HG changeset patch # User Steve Losh # Date 1471114663 0 # Node ID cc066896ae0cd8b7f39d10c3eefdefdd3d4fbfb1 # Parent 1a685df116abe5b1de08efe20f6fb7df2c144ebb Add `clampf` diff -r 1a685df116ab -r cc066896ae0c losh.lisp --- a/losh.lisp Sat Aug 13 18:29:24 2016 +0000 +++ b/losh.lisp Sat Aug 13 18:57:43 2016 +0000 @@ -269,9 +269,6 @@ ,@(substitute access-expr '% arguments)))) ,store-expr))) -(defmacro mulf (place n) - "Multiply `place` by `n` in-place." - `(zap% ,place #'* % ,n)) (defmacro zapf (&rest args) "Zap each place with each function." @@ -279,6 +276,14 @@ ,@(iterate (for (place function) :on args :by #'cddr) (collect `(zap% ,place ,function %))))) +(defmacro mulf (place n) + "Multiply `place` by `n` in-place." + `(zap% ,place #'* % ,n)) + +(defmacro clampf (place from to) + "Clamp `place` between `from` and `to` in-place." + `(zap% ,place #'clamp ,from ,to %)) + ;;;; Lists (defun take (n list) diff -r 1a685df116ab -r cc066896ae0c package.lisp --- a/package.lisp Sat Aug 13 18:29:24 2016 +0000 +++ b/package.lisp Sat Aug 13 18:57:43 2016 +0000 @@ -31,8 +31,9 @@ #:zap% #:% + #:zapf #:mulf - #:zapf + #:clampf #:take