Loops/Break: Difference between revisions
no edit summary
(Applesoft BASIC) |
No edit summary |
||
Line 1,157:
10
</pre>
=={{header|Emacs Lisp}}==
<lang lisp>(defun get-result (param)
;; According to the emacs lisp maual, the definition of ``catch'' is:
;; (catch 'symbol ..BODY...)
;; it returns either the last expression evaluated in BODY or the value given by ``throw''
(catch 'loop-break
(if (string= param "break")
(throw 'loop-break "breaked")
"pass") ) )</lang>
Example:
<lang lisp>(defun get-result (param)
(catch 'loop-break
(if (string= param "break")
(throw 'loop-break "breaked")
"pass") ) )
(get-result "break")
;; returns "breaked"
(get-result "break")
;; returns "pass"
</lang>
=={{header|D}}==
|