Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tutorials:beginner:failure_handling [2019/07/16 11:34] – cpo | tutorials:beginner:failure_handling [2022/03/15 13:41] – [Recovering from the failure] schimpf | ||
---|---|---|---|
Line 107: | Line 107: | ||
(defparameter *max-bound* 10.5) | (defparameter *max-bound* 10.5) | ||
- | (defun navigate (?v) | + | (defun navigate (&key ((: |
+ | & | ||
+ | (declare (type (or list null) ?target)) | ||
(flet ((out-of-bounds (pose) | (flet ((out-of-bounds (pose) | ||
| | ||
Line 116: | Line 118: | ||
(whenever ((fl-funcall #' | (whenever ((fl-funcall #' | ||
(error ' | (error ' | ||
- | (exe: | + | (exe: |
</ | </ | ||
Line 191: | Line 193: | ||
(defparameter *max-bound* 10.5) | (defparameter *max-bound* 10.5) | ||
- | (defun navigate (?v) | + | (defun navigate (&key ((: |
+ | & | ||
+ | (declare (type (or list null) ?target)) | ||
(flet ((out-of-bounds (pose) | (flet ((out-of-bounds (pose) | ||
| | ||
Line 197: | Line 201: | ||
(not (and (< *min-bound* x *max-bound*) | (not (and (< *min-bound* x *max-bound*) | ||
(< *min-bound* y *max-bound*)))))) | (< *min-bound* y *max-bound*)))))) | ||
- | | + | |
((out-of-bounds-error (e) | ((out-of-bounds-error (e) | ||
| | ||
| | ||
(let ((?corr-v (list | (let ((?corr-v (list | ||
- | (max 0.6 (min 10.4 (car ?v))) | + | (max 0.6 (min 10.4 (car ?target))) |
- | (max 0.6 (min 10.4 (cadr ?v))) | + | (max 0.6 (min 10.4 (cadr ?target))) |
0))) | 0))) | ||
| | ||
Line 212: | Line 216: | ||
(whenever ((fl-funcall #' | (whenever ((fl-funcall #' | ||
(error ' | (error ' | ||
- | (exe: | + | (exe: |
(defun recover-from-oob (& | (defun recover-from-oob (& | ||
Line 247: | Line 251: | ||
<code lisp> | <code lisp> | ||
(in-package :tut) | (in-package :tut) | ||
- | + | ||
- | (defun draw-house () | + | (defun draw-house (&key ((:shape ?shape)) |
+ | & | ||
+ | (declare (type (or keyword) ?shape)) | ||
(with-fields (x y) | (with-fields (x y) | ||
(value *turtle-pose*) | (value *turtle-pose*) | ||
Line 259: | Line 265: | ||
(exe: | (exe: | ||
- | (defun draw-simple-shape (vertices) | + | (defun draw-simple-shape (&key |
+ | ((:vertices | ||
+ | & | ||
+ | (declare (type (or list null) ?vertices)) | ||
(mapcar | (mapcar | ||
| | ||
| | ||
- | | + | ?vertices)) |
+ | |||
(defun navigate-without-pen (?target) | (defun navigate-without-pen (?target) | ||
(exe: | (exe: | ||
(exe: | (exe: | ||
(exe: | (exe: | ||
+ | |||
(defparameter *min-bound* 0.5) | (defparameter *min-bound* 0.5) | ||
(defparameter *max-bound* 10.5) | (defparameter *max-bound* 10.5) | ||
- | + | ||
- | (defun navigate (?v) | + | (defun navigate (&key ((:target ?target)) |
+ | & | ||
+ | (declare (type (or list null) ?target)) | ||
(flet ((out-of-bounds (pose) | (flet ((out-of-bounds (pose) | ||
| | ||
Line 279: | Line 291: | ||
(not (and (< *min-bound* x *max-bound*) | (not (and (< *min-bound* x *max-bound*) | ||
(< *min-bound* y *max-bound*)))))) | (< *min-bound* y *max-bound*)))))) | ||
- | | + | |
((out-of-bounds-error (e) | ((out-of-bounds-error (e) | ||
| | ||
| | ||
(let ((?corr-v (list | (let ((?corr-v (list | ||
- | (max 0.6 (min 10.4 (car ?v))) | + | (max 0.6 (min 10.4 (car ?target))) |
- | (max 0.6 (min 10.4 (cadr ?v))) | + | (max 0.6 (min 10.4 (cadr ?target))) |
0))) | 0))) | ||
| | ||
Line 294: | Line 306: | ||
(whenever ((fl-funcall #' | (whenever ((fl-funcall #' | ||
(error ' | (error ' | ||
- | (exe: | + | (exe: |
(defun recover-from-oob (& | (defun recover-from-oob (& |