((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/basic-sequences" "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 "Fundamental sequence operations" (p "This module provides the minimum necessary to handle linear container datatypes under a common sequence interface. It's written primary to be used in the bindings egg but secondary to be extendable to a full-fledged sequence package.") (pre "") (section 3 "Documentation" (section 4 "basic-sequences" (def (sig (procedure "(basic-sequences sym ..)" (id basic-sequences))) (p "documentation procedure. Shows the exported symbols and the syntax of such an exported symbol, respectively."))) (section 4 "seq-exception" (def (sig (procedure "(seq-exception loc msg . args)" (id seq-exception))) (p "generates a composite condition of type (exn sequence) with location loc, message msg and arguments args."))) (section 4 "seq-ref" (def (sig (procedure "(seq-ref seq n)" (id seq-ref))) (p "returns the nth item of the generic sequence seq"))) (section 4 "seq-tail" (def (sig (procedure "(seq-tail seq n)" (id seq-tail))) (p "returns the tail of the generic sequence seq, starting at n"))) (section 4 "seq-car" (def (sig (procedure "(seq-car seq)" (id seq-car))) (p "returns the zeroth item of the generic sequence seq"))) (section 4 "seq-cdr" (def (sig (procedure "(seq-cdr seq)" (id seq-cdr))) (p "returns the tail of the generic sequence seq, starting at 1"))) (section 4 "seq?" (def (sig (procedure "(seq? xpr)" (id seq?))) (p "checks, if xpr is a sequence"))) (section 4 "seq-null?" (def (sig (procedure "(seq-null? seq)" (id seq-null?))) (p "checks, if seq is empty."))) (section 4 "seq-random-access?" (def (sig (procedure "(seq-random-access? seq)" (id seq-random-access?))) (p "checks, if seq is randomly accessible"))) (section 4 "seq-db" (def (sig (procedure "(seq-db)" (id seq-db))) (p "shows the sequence database")) (def (sig (procedure "(seq-db type? ref: ref tail: tail maker: maker ra?: random-access?)" (id seq-db))) (p "adds a new custom sequence type with predicate type? and keyword arguments ref: tail: maker: ra?: naming procedures to be later accessed as seq-ref, seq-tail, seq-maker and seq-randoam-access? respectively.")))) (section 3 "Convenience procedures" (section 4 "cons*" (def (sig (procedure "(cons* arg ....)" (id cons*))) (p "iterative version of cons"))) (section 4 "list-of" (def (sig (procedure "(list-of ok? ...)" (id list-of))) (p "returns a predicate which checks, if its argument is a list which passes every predicate ok? ..."))) (section 4 "pseudo-list-of" (def (sig (procedure "(pseudo-list-of ok? ...)" (id pseudo-list-of))) (p "returns a predicate which checks, if its argument is a pseudo-list, which passes every predicate ok? ..."))) (section 4 "vector-of" (def (sig (procedure "(vector-of ok? ...)" (id vector-of))) (p "returns a predicate which checks, if its argument is a vector which passes every predicate ok? ..."))) (section 4 "tagged-vector" (def (sig (procedure "(tagged-vector kw arg ...)" (id tagged-vector))) (p "generates a tagged vector with keyword kw and args arg ..."))) (section 4 "tagged-vector?" (def (sig (procedure "(tagged-vector? xpr)" (id tagged-vector?))) (p "type predicate"))) (section 4 "tagged-vector-of" (def (sig (procedure "(tagged-vector-of ok? ...)" (id tagged-vector-of))) (p "generates a tagged vector predicate which checks all of its arguments"))) (section 4 "tagged-vector-ref" (def (sig (procedure "(tagged-vector-ref tv k)" (id tagged-vector-ref))) (p "access to kth item of tagged vector tv"))) (section 4 "tagged-vector-tail" (def (sig (procedure "(tagged-vector-tail tv k)" (id tagged-vector-tail))) (p "returns a tagged subvector of tv starting at k"))) (section 4 "thunk" (def (sig (syntax "(thunk xpr ....)" (id thunk))) (p "generates a thunk with body xpr ...."))) (section 4 "thunk?" (def (sig (procedure "(thunk? xpr)" (id thunk?))) (p "checks if xpr is a thunk, i.e. a nullary procedure"))) (section 4 "symbol-dispatcher" (def (sig (procedure "(symbol-dispatcher alist)" (id symbol-dispatcher))) (p "creates a documentation procedure as used in all modules of this library.")))) (section 3 "Requirements" (p "simple-exceptions")) (section 3 "Usage" (highlight scheme "\n(use simple-exceptions basic-sequences)\n")) (section 3 "Examples" (highlight scheme "\n(require-library basic-sequences simple-tests arrays)\n(import basic-sequences\n        simple-tests\n        (only arrays array array? array-ref array-tail array->list))\n\n(seq-db array? ref: array-ref tail: array-tail maker: array ra?: #t)\n(define lst '(0 1 2 3 4))\n(define pls '(0 1 2 3 . 4))\n(define vec #(0 1 2 3 4))\n(define arr (array 0 1 2 3 4))\n(define str \"01234\")\n(seq-ref lst 3) ;-> 3\n(seq-ref pls 3) ; -> 3\n(seq-tail pls 4) ; -> 4\n(seq-ref vec 3) ; -> 3\n(seq-ref arr 3) ; -> 3\n(seq-ref str 3) ; -> #\\3\n(seq-tail lst 3) ; -> '(3 4)\n(seq-tail pls 3) ; -> '(3 . 4)\n(seq-tail vec 3) ; -> #(3 4)\n(array->list (seq-tail arr 3)) ; -> '(3 4)\n(seq-tail str 3) ; -> \"34\"\n(seq-null? (seq-tail lst 5)) ; -> #t\n(seq-null? (seq-tail vec 5)) ; -> #t\n(seq-null? (seq-tail arr 5)) ; -> #t\n(seq-null? (seq-tail str 5)) ; -> #t\n(seq-null? (seq-tail pls 4)) ; -> #t\n(seq? lst) ; -> #t\n(seq? pls) ; -> #t\n(seq? vec) ; -> #t\n(seq? str) ; -> #t\n(seq? arr) ; -> #t\n((seq-of integer? odd?) arr) ; -> #f\n((seq-of integer? odd?) #(1 3 5 7)) ; -> #t\n(seq-maker lst) ; -> list\n(seq-maker pls) ; -> cons*\n(seq-maker vec) ; -> vector\n(seq-random-access? arr) ; -> #t\n(seq-random-access? vec) ; -> #t\n(seq-random-access? lst) ; -> #f\n(cons* 0 1 2 3) ; -> '(0 1 2 . 3)\n(thunk? (thunk 1 2 3)) ; -> #t\n(define tv (tagged-vector x: 0 1 2 3))\n(tagged-vector-ref tv 0) ; -> x:\n(define null (tagged-vector x:))\n(tagged-vector? null) ; -> #t\n(seq? null) ; -> #t\n(seq-null? null) ; -> #f\n(define tv3 (tagged-vector-tail tv 3))\n(tagged-vector-ref tv3 0) ; -> x:\n(define tv4 (tagged-vector-tail tv 4))\n(tagged-vector? tv4) ; -> #t\n(seq-null? tv4) ; -> #f\n(define tv5 (tagged-vector-tail tv 5))\n(seq-null? tv5) ; -> #t\n(condition-case (tagged-vector-ref tv5 0)\n  ((exn sequence) #f)) ; -> #f\n"))) (section 2 "Last update" (p "Jul 12, 2018")) (section 2 "Author" (p (int-link "/users/juergen-lorenz" "Juergen Lorenz"))) (section 2 "License" (pre "Copyright (c) 2011-2018, 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 "2.2 ; fixed the bugfix") (dt "2.1 ; bug in tagged-vector? fixed, thanks to Martin Schneeweis") (dt "2.0 ; tagged vectors added to be used with algebraic types") (dt "1.0") (dd "initial import"))))