cc066896ae0c

Add `clampf`
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sat, 13 Aug 2016 18:57:43 +0000
parents 1a685df116ab
children ccba9d609da8
branches/tags (none)
files losh.lisp package.lisp

Changes

--- 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)
--- 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