Changeset 39706 in project


Ignore:
Timestamp:
03/14/21 20:10:48 (6 weeks ago)
Author:
Kon Lovett
Message:

srfi-41 << streams, stop record-variants `check-...' gen, add queue ctors, single import

Location:
release/5/srfi-41/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • release/5/srfi-41/trunk/srfi-41.egg

    r39705 r39706  
    22
    33((synopsis "SRFI 41 (Streams)")
    4  (version "2.0.3")
     4 (version "2.0.4")
    55 (category data)
    66 (author "Philip L. Bewig, for CHICKEN by Kon Lovett")
     
    1010 (test-dependencies check-errors)
    1111 (components
     12  (extension srfi-41
     13    (types-file)
     14    (component-dependencies streams)
     15    (csc-options "-O3" "-d1" "-strict-types" "-no-procedure-checks-for-toplevel-bindings"))
    1216  (extension streams
    13     (types-file)
    14     (component-dependencies srfi-41)
    15     (csc-options "-O3" "-d1" "-strict-types" "-no-procedure-checks-for-toplevel-bindings"))
    16   (extension srfi-41
    1717    (types-file)
    1818    (component-dependencies streams-primitive streams-derived)
     
    2323  (extension streams-derived
    2424    (types-file)
     25    (component-dependencies streams-primitive)
    2526    (csc-options "-O3" "-d1" "-strict-types" "-no-procedure-checks" "-no-bound-checks"))
    2627  (extension streams-utils
     
    3031  (extension streams-math
    3132    (types-file)
    32     (component-dependencies streams-utils)
     33    (component-dependencies streams streams-utils)
    3334    (csc-options "-O3" "-d1" "-strict-types" "-no-procedure-checks-for-toplevel-bindings"))
    3435  (extension streams-queue
  • release/5/srfi-41/trunk/srfi-41.scm

    r38514 r39706  
    1717; THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    1818
    19 (module srfi-41
     19(module srfi-41 ()
    2020
    21 (;export
    22   ; srfi
    23   stream-null
    24   stream-cons
    25   stream?
    26   stream-null?
    27   stream-pair?
    28   stream-car
    29   stream-cdr
    30   stream-lambda
    31   define-stream
    32   list->stream
    33   port->stream
    34   stream
    35   stream->list
    36   stream-append
    37   stream-concat
    38   stream-constant
    39   stream-drop
    40   stream-drop-while
    41   stream-filter
    42   stream-fold
    43   stream-for-each
    44   stream-from
    45   stream-iterate
    46   stream-length
    47   stream-let
    48   stream-map
    49   stream-match
    50   stream-of
    51   stream-range
    52   stream-ref
    53   stream-reverse
    54   stream-scan
    55   stream-take
    56   stream-take-while
    57   stream-unfold
    58   stream-unfolds
    59   stream-zip
    60   ; extras
    61   stream-occupied?
    62   check-stream
    63   error-stream
    64   check-stream-occupied
    65   error-stream-occupied)
     21(import scheme
     22  (chicken module)
     23  (chicken platform))
    6624
    67 (import scheme)
    68 (import (chicken module))
    69 (import (chicken platform))
    70 (import streams-primitive)
    71 (import streams-derived)
     25(import streams)
     26(reexport streams)
    7227
    7328(register-feature! 'srfi-41)
    74 (register-feature! 'streams)
    7529
    76 ) ;module streams
     30) ;module  srfi-41
  • release/5/srfi-41/trunk/streams-derived.scm

    r39705 r39706  
    6666    error-input-port error-list))
    6767
    68 (include "chicken-primitive-object-inlines")
    69 (include "streams-inlines")
    70 (include "inline-type-checks")
     68(include-relative "chicken-primitive-object-inlines")
     69(include-relative "streams-inlines")
     70(include-relative "inline-type-checks")
    7171
    7272;;;
  • release/5/srfi-41/trunk/streams-math.scm

    r38514 r39706  
    3434  fibonacci-stream)
    3535
    36 (import scheme)
    37 (import (chicken base))
    38 (import (chicken type))
    39 (import streams)
    40 (import streams-utils)
     36(import scheme
     37  (chicken base)
     38  (chicken type)
     39  streams
     40  streams-utils)
    4141
    42 (include "chicken-primitive-object-inlines")
    43 (include "streams-inlines")
     42(include-relative "chicken-primitive-object-inlines")
     43(include-relative "streams-inlines")
    4444
    4545;;; Section Combinators
    4646
    47 (: left-section ((procedure (#!rest) *) #!rest -> (procedure (#!rest) *)))
    48 ;
    49 (define (left-section fn . args)
    50   (lambda xs (apply fn (append args xs))) )
     47(define (left-section fn . args) (lambda xs (apply fn (append args xs))))
    5148
    5249;;;
  • release/5/srfi-41/trunk/streams-queue.scm

    r38514 r39706  
    1 ;;;; streams-queue.scm
     1;;;; streams-queue.scm  -*- Scheme -*-
    22;;;; Kon Lovett, Feb '19
    33;;;; Kon Lovett, Aug '10
     4
    45;;;; From "samples.ss"
    5 :::: Provides a functional queue abstraction using streams.
     6;;;; Provides a functional queue abstraction using streams.
    67
    78(module streams-queue
    89
    910(;export
     11  ;original
    1012  queue-null
    1113  queue-null?
    1214  queue-cons
    1315  queue-head
    14   queue-tail)
     16  queue-tail
     17  ;extras
     18  make-queue
     19  queue)
    1520
    16 (import scheme)
    17 (import (chicken base))
    18 (import (chicken type))
    19 (import (only type-errors error-pair))
    20 (import streams)
     21(import scheme
     22  (chicken base)
     23  (chicken type)
     24  streams
     25  (only type-errors error-pair))
    2126
    22 (include "chicken-primitive-object-inlines")
    23 (include "streams-inlines")
    24 (include "inline-type-checks")
     27(include-relative "chicken-primitive-object-inlines")
     28(include-relative "streams-inlines")
     29(include-relative "inline-type-checks")
    2530
    2631;;;
    2732
    28 (define-inline (queue-check f r)
     33(define-inline (finalize-queue f r)
    2934  (if (%fx< (stream-length r) (stream-length f))
    3035    (%cons f r)
    3136    (%cons (stream-append f (stream-reverse r)) stream-null) ) )
     37
     38;;;
    3239
    3340(define queue-null
     
    3946(define (queue-cons q x)
    4047  (%check-pair 'queue-cons q 'queue)
    41   (queue-check (%car q) (stream-cons x (%cdr q))) )
     48  (finalize-queue (%car q) (stream-cons x (%cdr q))) )
    4249
    4350(define (queue-head q)
     
    5057  (%check-pair 'queue-tail q 'queue)
    5158  (if (stream-null? (%car q))
    52     (error 'queue-head "empty queue")
    53     (queue-check (stream-cdr (%car q)) (%cdr q)) ) )
     59    (error 'queue-tail "empty queue")
     60    (finalize-queue (stream-cdr (%car q)) (%cdr q)) ) )
     61
     62;;
     63
     64; l 1 2 3 => q 3 2 1
     65(define (make-queue ls)
     66  (let loop ((ls ls) (q queue-null))
     67    (if (%null? ls) q
     68      (loop (%cdr ls) (queue-cons q (%car ls))) ) ) )
     69
     70; 1 2 3 => q 3 2 1
     71(define (queue . rest) (apply make-queue rest))
    5472
    5573) ;streams-queue
  • release/5/srfi-41/trunk/streams-utils.scm

    r38514 r39706  
    4747  binary-tree-same-fringe?)
    4848
    49 (import scheme)
    50 (import (chicken base))
    51 (import (chicken type))
    52 (import (only type-errors
    53   error-list error-procedure
    54   error-string error-natural-integer))
    55 (import streams)
    56 
    57 (include "chicken-primitive-object-inlines")
    58 (include "streams-inlines")
    59 (include "inline-type-checks")
     49(import scheme
     50  (chicken base)
     51  (chicken type)
     52  streams
     53  (only type-errors
     54    error-list error-procedure
     55    error-string error-natural-integer))
     56
     57(include-relative "chicken-primitive-object-inlines")
     58(include-relative "streams-inlines")
     59(include-relative "inline-type-checks")
    6060
    6161;;;
  • release/5/srfi-41/trunk/streams.scm

    r38514 r39706  
    1919(module streams ()
    2020
    21 (import scheme)
    22 (import (chicken module))
    23 (import (srfi 41))
    24 (reexport (srfi 41))
     21(import scheme
     22  (chicken module)
     23  (chicken platform))
     24
     25(import streams-primitive)
     26(reexport streams-primitive)
     27
     28(import streams-derived)
     29(reexport streams-derived)
     30
     31(register-feature! 'streams)
    2532
    2633) ;module streams
  • release/5/srfi-41/trunk/tests/srfi-41-test.scm

    r38514 r39706  
    11;;;; srfi-41-test.scm  -*- Scheme -*-
    2 
    3 ;(import section-combinators)
    4 (import streams)
    5 (import streams-utils)
    6 (import streams-math)
    7 (import type-errors)
    8 (import (chicken condition))
    9 
    10 ;;; Section Combinators
    11 
    12 ;
    13 (define (left-section fn . args)
    14   (lambda xs (apply fn (append args xs))) )
    15 
    16 ;
    17 (define (right-section fn . args)
    18   ;(append xs args) = (reverse (append (reverse args) (reverse xs)))
    19   (lambda xs (apply fn (append xs args))) )
    202
    213; Copyright (C) 2007 by Philip L. Bewig of Saint Louis, Missouri, USA.  All rights
     
    3214; CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
    3315; THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     16
     17(import streams)
     18(import streams-utils)
     19(import streams-math)
     20(import type-errors)
     21(import (chicken condition))
     22
     23;;;
     24
     25;;section-combinators
     26
     27(define (left-section fn . args) (lambda xs (apply fn (append args xs))))
     28
     29;(append xs args) = (reverse (append (reverse args) (reverse xs)))
     30(define (right-section fn . args) (lambda xs (apply fn (append xs args))))
    3431
    3532;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; unit tests
Note: See TracChangeset for help on using the changeset viewer.