This is an extension to the CL:LOOP macro that provides CONTINUE,
TAG and GO keywords.
CONTINUE allows you to skip the current loop iteration (similar to
continue in other languages).
TAG and GO provide finer control similar to TAGBODY.
SBCL, CMUCL, CCL, Allegro CL, CLASP, ABCL, ECL.
CONTINUE:
(loop #:for i #:from 1 #:to 6
#:when (zerop (mod i 2))
#:continue
#:collect i)
; => (1 3 5)For finer flow control you can use TAG and GO:
(loop #:for i #:from 1 #:to 4
#:when (zerop (mod i 2))
#:go end
#:collect i
#:tag end
#:do (format t "Logging: ~A~%" i))
; >> Logging: 1
; >> Logging: 2
; >> Logging: 3
; >> Logging: 4
; => (1 3)This library is available in ultralisp.
Alternatively you can clone this repository to the ~/quicklisp/local-projects directory.
Load the system with ql:quickload or asdf:load-system
(ql:quickload :loop-continue) ; or (asdf:load-system :loop-continue)To enable the extension use the enable function:
(loop-continue:enable)
; => T
;; Now you can use CONTINUE, TAG and GO in your loops!You can also disable the extension with disable:
(loop-continue:disable)
; => NIL
;; Now CONTINUE, TAG and GO don't work again.Feel free to report bugs or make suggestions by filing an issue on github.
Feel free to submit pull requests on github as well.
Copyright 2023 Gleefre
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.