((section 2 "Outdated egg!" (p "This is an egg for CHICKEN 4, the unsupported old release.  You're almost certainly looking for " (int-link "/eggref/5/loops" "the CHICKEN 5 version of this egg") ", if it exists.") (p "If it does not exist, there may be equivalent functionality provided by another egg; have a look at the " (link "https://wiki.call-cc.org/chicken-projects/egg-index-5.html" "egg index") ". Otherwise, please consider porting this egg to the current version of CHICKEN.") (tags "egg") (toc)) (section 2 "loops" (p "This module contains some easy looping macros.  The documentation is included in the module, i.e. there is a dispatcher routine with the modules name, loops, which when called without arguments returns a list of the exported symbols, and when called with such a symbol prints that symbols documentation.") (highlight scheme "(loops)") (p "returns the list of exported symbols, namely") (highlight scheme "(do-for do-forever do-list do-times do-until do-while)") (highlight scheme "(loops 'do-list)") (p "shows the documentation of do-list, i.e. something like") (highlight scheme "loop along a list\n(do-list var lst xpr . xpr)\nexecutes xpr . xps for var in lst.") (section 3 "Programming interface" (section 4 "do-for" (def (sig (syntax "(do-for var (start stop [step]) xpr . xprs)" (id do-for))) (p "where step is optional and defaults to 1. Executes xpr . xprs for var in [start stop[ with steps step."))) (section 4 "do-forever" (def (sig (syntax "(do-forever xpr . xprs)" (id do-forever))) (p "executes xpr . xprs until exit is called.") (p "This macro is unhygienic by design. It exports the symbol exit into the macro's scope."))) (section 4 "do-list" (def (sig (syntax "(do-list var lst xpr . xprs)" (id do-list))) (p "executes xpr . xprs for var in a list lst."))) (section 4 "do-times" (def (sig (syntax "(do-times var upto xpr0 . xprs)" (id do-times))) (p "executes xpr . xprs for var in [0 upto["))) (section 4 "do-until" (def (sig (syntax "(do-until test? xpr . xprs)" (id do-until))) (p "executes xpr . xprs while test? is false"))) (section 4 "do-while" (def (sig (syntax "(do-while test? xpr . xprs)" (id do-while))) (p "executes xpr . xprs while test? is true")))) (section 3 "Usage" (highlight scheme "(use loops)")) (section 3 "Examples" (highlight scheme "(use loops)\n\n(let ((lst '()))\n  (do-times i (+ 2 3)\n    (set! lst (cons i lst)))\n  lst)\n; -> '(4 3 2 1 0)\n\n(let ((lst '()))\n  (do-list i '(1 2 3) (set! lst (cons i lst)))\n  lst)\n; -> '(3 2 1)\n\n(let ((lst '()))\n  (do-for i (1 5) (set! lst (cons i lst)))\n  (reverse lst)) ; -> '(1 2 3 4)\n\n(let ((lst '()))\n  (do-for i (1 65 i) (set! lst (cons i lst)))\n  (reverse lst))\n; -> '(1 2 4 8 16 32 64)\n\n(let ((n 4) (lst '()))\n  (do-while (<= 0 n)\n    (set! lst (cons n lst))\n    (set! n (- n 1)))\n  lst)\n; -> '(0 1 2 3 4)\n\n(let ((n 4) (lst '()))\n  (do-until (> 0 n)\n    (set! lst (cons n lst))\n    (set! n (- n 1)))\n  lst)\n; -> '(0 1 2 3 4)\n\n(let ((n 3) (lst '()))\n  (do-forever\n    (if (zero? n) (exit lst))\n    (set! lst (cons 'a lst))\n    (set! n (- n 1))))\n; -> '(a a a)")) (section 3 "Requirements" (p "None"))) (section 2 "Last update" (p "Feb 15, 2014")) (section 2 "Author" (p (int-link "/users/juergen-lorenz" "Juergen Lorenz"))) (section 2 "License" (pre "Copyright (c) 2011-2014, Juergen Lorenz\nAll rights reserved.") (pre "Redistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\nRedistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n\nRedistributions in binary form must reproduce the above copyright\nnotice, this list of conditions and the following disclaimer in the\ndocumentation and/or other materials provided with the distribution.\nNeither the name of the author nor the names of its contributors may be\nused to endorse or promote products derived from this software without\nspecific prior written permission. \n  \nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS\nIS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED\nTO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A\nPARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nHOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\nTO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\nPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.")) (section 2 "Version History" (dl (dt "1.0.4") (dd "tests ported to simple-tests") (dt "1.0") (dd "dependency on contracts removed") (dt "0.2") (dd "dependency removed") (dt "0.1") (dd "initial import"))))