Loops/Break: Difference between revisions

No edit summary
Line 1,159:
 
=={{header|Emacs Lisp}}==
<lang lisp>(defun get-resultwait_10 (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
(while 't
(if (string= param "break")
(let ((math (random 19)))
(throw 'loop-break "breaked")
(if (= math 10)
"pass") ) )
(progn (message "Found value: %d" math)
 
(get-resultthrow "'loop-break" math))
(message "current number is: %d" math) ) ) ) ) )
;; returns "breaked"
 
(get-result "break")
;; returns "pass"
 
(wait_10)</lang>
 
=={{header|D}}==
59

edits