Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
[[tags: egg]] [[toc:]] == simple-loops This module exports some simple loop macros. The syntax of some of them has changed, but the earlier versions are still valid, albeit deprecated. === The routines ==== simple-loops <procedure>(simple-loops [sym])</procedure> documentation-procedure; returns the list of exported symbols if called with no symbol, otherwise the signature of that exported symbol sym. ==== do-for <macro>(do-for (var start stop step) xpr . xprs)</macro> <macro>(do-for (var start stop) xpr . xprs)</macro> ;; deprecated: <macro>(do-for var (start stop step) xpr . xprs)</macro> <macro>(do-for var (start stop) xpr . xprs)</macro> for-loop: do xpr . xprs for var in [start stop[ with step defaulting to 1") ==== do-forever <macro>(do-forever xpr . xprs)</macro> endless loop: executes body xpr . xprs until exit is called, a symbol being defined behind the scenes. ==== do-list <macro>(do-list (var lst) xpr . xprs)</macro> ;; deprecated: <macro>(do-list var lst xpr . xprs)</macro> loop along a list: execute xpr . xprs for var in lst ==== do-times <macro>(do-times (k upto) xpr . xprs)</macro> ;; deprecated: <macro>(do-times k upto xpr . xprs)</macro> loops a fixed number of times: execute xpr . xprs for k in [0 upto[ ==== do-until <macro>(do-until test? xpr . xprs)</macro> until-loop: execute xpr . xprs while test? is false ==== do-while <macro>(do-while test? xpr . xprs)</macro> while-loop: execute xpr . xprs while test? is true === Requirements none === Example <enscript highlight=scheme> (import simple-loops) (let ((lst '())) (do-for (var 1 65 var) (set! lst (cons var lst))) (reverse lst)) ;-> '(1 2 4 8 16 32 64) (let ((n 3) (lst '())) (do-forever (if (zero? n) (exit lst)) (set! lst (cons 'a lst)) (set! n (- n 1)))) ;-> '(a a a) (let ((lst '())) (do-list (var '(1 2 3)) (set! lst (cons var lst))) lst) ;-> '(3 2 1) (let ((lst '())) (do-times (k (+ 2 3)) (set! lst (cons k lst))) lst) ;-> '(4 3 2 1 0) (let ((n 4) (lst '())) (do-until (> 0 n) (set! lst (cons n lst)) (set! n (- n 1))) lst) ;-> '(0 1 2 3 4) (let ((n 4) (lst '())) (do-while (<= 0 n) (set! lst (cons n lst)) (set! n (- n 1))) lst) ;-> '(0 1 2 3 4) </enscript> == Last update May 18, 2022 == Author [[/users/juergen-lorenz|Juergen Lorenz]] == License Copyright (c) 2013-2022, Juergen Lorenz All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. == Version History ; 1.0 : port from chicken-4 ; 2.0 : some loops with new syntax; the old syntax is deprecated
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you subtract 23 from 10?