Differences

This shows you the differences between two versions of the page.

Link to this comparison view

tutorials:beginner:failure_handling [2017/09/07 14:55]
cpo
tutorials:beginner:failure_handling [2017/09/07 15:14] (current)
cpo Beautified out of bounds check
Line 103: Line 103:
  
 <code lisp> <code lisp>
-(defparameter min-bound 0.5) +(defparameter ​*min-bound0.5) 
-(defparameter max-bound 10.5)+(defparameter ​*max-bound10.5)
  
 (defun move (?v) (defun move (?v)
Line 110: Line 110:
            ​(with-fields (x y)            ​(with-fields (x y)
                ​(value pose)                ​(value pose)
-             (if (or (x max-bound) (< min-bound) (> y max-bound) ​(< y min-bound)+             (not (and (< *min-bound* ​*max-bound*) 
-                 T))))+                       (< *min-bound*max-bound*))))))
     (pursue     (pursue
       (whenever ((fl-funcall #'​out-of-bounds *turtle-pose*))       (whenever ((fl-funcall #'​out-of-bounds *turtle-pose*))
Line 186: Line 186:
  
 <code lisp> <code lisp>
-(defparameter min-bound 0.5) +(defparameter ​*min-bound0.5) 
-(defparameter max-bound 10.5)+(defparameter ​*max-bound10.5)
  
 (defun move (?v) (defun move (?v)
Line 193: Line 193:
            ​(with-fields (x y)            ​(with-fields (x y)
                ​(value pose)                ​(value pose)
-             (if (or (x max-bound) (< min-bound) (> y max-bound) ​(< y min-bound)+             (not (and (< *min-bound* ​*max-bound*) 
-                 T))))+                       (< *min-bound*max-bound*))))))
     (with-failure-handling     (with-failure-handling
         ((out-of-bounds-error (e)         ((out-of-bounds-error (e)
Line 268: Line 268:
   (exe:​perform (a motion (type setting-pen) (off 0))))   (exe:​perform (a motion (type setting-pen) (off 0))))
  
-(defparameter min-bound 0.5) +(defparameter ​*min-bound0.5) 
-(defparameter max-bound 10.5)+(defparameter ​*max-bound10.5)
  
 (defun move (?v) (defun move (?v)
Line 275: Line 275:
            ​(with-fields (x y)            ​(with-fields (x y)
                ​(value pose)                ​(value pose)
-             (if (or (x max-bound) (< min-bound) (> y max-bound) ​(< y min-bound)+             (not (and (< *min-bound* ​*max-bound*) 
-                 T))))+                       (< *min-bound*max-bound*))))))
     (with-failure-handling     (with-failure-handling
         ((out-of-bounds-error (e)         ((out-of-bounds-error (e)