Code: Select all
(define (return x) x)Gives me a self-documenting way of avoiding both catch, throw and eval as well. Please criticize?
Code: Select all
(define (return x) x)Code: Select all
(define (parse-pawn-move s n)
(filter on-board?
(if (black-to-move? n)
(let (lst (list (next-diagl s)(next-diagr s)(next-row s)))
(if (= "6" (row s))
(append lst (list (next-row (next-row s))))
(return lst)))
(let (lst (list (prev-diagl s)(prev-diagr s)(prev-row s)))
(if (= "4" (row s))
(append lst (list (prev-row (prev-row s))))
(return lst))))))
Code: Select all
(define (parse-pawn-move s n)
(filter on-board?
(if (black-to-move? n)
(let (lst (list (next-diagl s)(next-diagr s)(next-row s)))
(if (= "6" (row s))
(append lst (list (next-row (next-row s))))
lst))
(let (lst (list (prev-diagl s)(prev-diagr s)(prev-row s)))
(if (= "4" (row s))
(append lst (list (prev-row (prev-row s))))
lst)))))Speaking of memory, thank you for reminding me of this little detail. And least I be accused of being original, here is a quote from Guy L. Steele Jr.The value of a call is the value of the last expression evaluated.
Kinda weak I'll admit--- but hey, what can I say!This function is occasionally useful as an argument to other functions that require functions as arguments (Got that?)
That's not the same thing. If I want to break a loop:That would imply that the idomatic use of catch and throw is never needed as well.
Code: Select all
(set 'foo (catch (dotimes (i 10) (if (= i 5) (throw i)))))