Outdated egg!

This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.

If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.

srfi-41

SRFI 41 for Chicken Scheme.

  1. Outdated egg!
  2. srfi-41
  3. Documentation
    1. Primitive
      1. Usage
      2. stream?
      3. stream-pair?
      4. stream-null?
      5. stream-occupied?
      6. stream-null
      7. stream-cons
      8. stream-lambda
      9. stream-car
      10. stream-cdr
    2. Derived
      1. Usage
      2. define-stream
      3. stream-of
      4. stream-let
      5. stream-match
      6. stream
      7. list->stream
      8. port->stream
      9. stream->list
      10. stream-append
      11. stream-concat
      12. stream-drop
      13. stream-drop-while
      14. stream-filter
      15. stream-fold
      16. stream-for-each
      17. stream-map
      18. stream-from
      19. stream-iterate
      20. stream-length
      21. stream-range
      22. stream-ref
      23. stream-reverse
      24. stream-scan
      25. stream-unfold
      26. stream-unfolds
      27. stream-zip
    3. Utilities
      1. Usage
      2. stream-intersperse
      3. stream-permutations
      4. file->stream
      5. stream-split
      6. stream-unique
      7. stream-fold-one
      8. stream-member
      9. stream-merge
      10. stream-partition
      11. stream-finds
      12. stream-find
      13. stream-remove
      14. stream-every
      15. stream-any
      16. stream-and
      17. stream-or
      18. stream-fold-right
      19. stream-fold-right-one
      20. stream-assoc
      21. stream-equal?
      22. stream-quick-sort
      23. stream-insertion-sort
      24. stream-merge-sort
      25. stream-maximum
      26. stream-minimum
      27. binary-tree-same-fringe?
    4. Math Utilities
      1. Usage
      2. stream-max
      3. stream-min
      4. stream-sum
      5. odd-numbers-stream
      6. even-numbers-stream
      7. cardinal-numbers-stream
      8. natural-numbers-stream
      9. prime-numbers-stream
      10. hamming-sequence-stream
  4. Examples
    1. Usage
  5. Requirements
  6. Author
  7. Version history
  8. License

Documentation

See the SRFI-41 Document.

Primitive

Usage

(require-extension streams-primitive)

stream?

[procedure] (stream? OBJECT) => boolean

stream-pair?

[procedure] (stream-pair? OBJECT) => boolean

stream-null?

[procedure] (stream-null? OBJECT) => boolean

stream-occupied?

[procedure] (stream-occupied? OBJECT) => boolean

Inverse of stream-null?.

stream-null

[constant] stream-null

The null stream value.

stream-cons

[syntax] (stream-cons OBJECT STREAM) => stream

stream-lambda

[syntax] (stream-lambda FORMALS BODY ...) => procedure

stream-car

[procedure] (stream-car STREAM) => *

stream-cdr

[procedure] (stream-cdr STREAM) => stream

Derived

Usage

(require-extension streams-derived)

define-stream

[syntax] (define-stream (NAME [FORMAL...]) BODY...)

stream-of

[syntax] (stream-of EXPRESSION (VARIABLE in STREAM)/(VARIABLE is EXPRESSION)/PREDICATE ...) => stream

stream-let

[syntax] (stream-let TAG ((NAME VALUE)...) BODY...)

stream-match

[syntax] (stream-match STREAM-EXPRESSION CLAUSE...)

stream

[syntax] (stream OBJECT...) => stream

list->stream

[procedure] (list->stream LIST) => stream

port->stream

[procedure] (port->stream [PORT (current-input-port)]) => stream

stream->list

[procedure] (stream->list [COUNT #f] STREAM) => list

stream-append

[procedure] (stream-append STREAM...) => stream

stream-concat

[procedure] (stream-concat STREAM) => stream

Flatten a stream of streams.

stream-drop

[procedure] (stream-drop COUNT STREAM) => stream

stream-drop-while

[procedure] (stream-drop-while PREDICATE STREAM) => stream

stream-filter

[procedure] (stream-filter PREDICATE STREAM) => stream

stream-fold

[procedure] (stream-fold FUNCTION BASE STREAM...) => *

stream-for-each

[procedure] (stream-for-each FUNCTION STREAM...) => stream

stream-map

[procedure] (stream-map FUNCTION STREAM...) => stream

stream-from

[procedure] (stream-from FIRST [STEP 1]) => stream

stream-iterate

[procedure] (stream-iterate FUNCTION BASE) => stream

stream-length

[procedure] (stream-length STREAM) => FIXNUM

stream-range

[procedure] (stream-range FIRST PAST [STEP (if (< FIRST PAST) 1 -1)]) => stream

stream-ref

[procedure] (stream-ref STREAM INDEX) => *

stream-reverse

[procedure] (stream-reverse STREAM) => stream

stream-scan

[procedure] (stream-scan FUNCTION BASE STREAM) => stream

stream-unfold

[procedure] (stream-unfold MAPPER PREDICATE GENERATOR BASE) => stream

stream-unfolds

[procedure] (stream-unfolds GENERATOR SEED) => stream

stream-zip

[procedure] (stream-zip STREAM...) => stream

Utilities

Usage

(require-extension streams-utils)

stream-intersperse

[procedure] (stream-intersperse STREAM OBJECT) => stream

stream-permutations

[procedure] (stream-permutations STREAM) => stream

file->stream

[procedure] (file->stream FILENAME [READER read-char]) => stream

stream-split

[procedure] (stream-split COUNT STREAM) => (values STREAM STREAM)

stream-unique

[procedure] (stream-unique =? STREAM) => stream

stream-fold-one

[procedure] (stream-fold-one FUNCTION STREAM) => stream

stream-member

[procedure] (stream-member =? OBJECT STREAM) => stream

stream-merge

[procedure] (stream-merge <? STREAM ...) => stream

stream-partition

[procedure] (stream-partition PREDICATE STREAM) => stream

stream-finds

[procedure] (stream-finds =? OBJECT STREAM) => stream

stream-find

[procedure] (stream-find =? OBJECT STREAM) => stream

stream-remove

[procedure] (stream-remove PREDICATE STREAM) => stream

stream-every

[procedure] (stream-every PREDICATE STREAM) => boolean

stream-any

[procedure] (stream-any PREDICATE STREAM) => boolean

stream-and

[procedure] (stream-and STREAM) => boolean

stream-or

[procedure] (stream-or STREAM) => boolean

stream-fold-right

[procedure] (stream-fold-right FUNCTION BASE STREAM) => *

stream-fold-right-one

[procedure] (stream-fold-right-one FUNCTION STREAM) => *

stream-assoc

[procedure] (stream-assoc KEY STREAM [=? equal?]) => *

stream-equal?

[procedure] (stream-equal? =? STREAM1 STREAM2) => boolean

stream-quick-sort

[procedure] (stream-quick-sort <? STREAM) => stream

stream-insertion-sort

[procedure] (stream-insertion-sort <? STREAM) => stream

stream-merge-sort

[procedure] (stream-merge-sort <? STREAM) => stream

stream-maximum

[procedure] (stream-maximum <? STREAM) => *

stream-minimum

[procedure] (stream-minimum <? STREAM) => *

binary-tree-same-fringe?

[procedure] (binary-tree-same-fringe? TREE1 TREE2) => boolean

TREE1 and TREE2 are binary-tree nodes, so either () or pair.

Lazy version of the same fringe.

Math Utilities

Usage

(require-extension streams-math)

stream-max

[procedure] (stream-max STREAM) => *

stream-min

[procedure] (stream-min STREAM) => *

stream-sum

[constant] stream-sum

odd-numbers-stream

[constant] odd-numbers-stream

even-numbers-stream

[constant] even-numbers-stream

cardinal-numbers-stream

[constant] cardinal-numbers-stream

natural-numbers-stream

[constant] natural-numbers-stream

prime-numbers-stream

[constant] prime-numbers-stream

hamming-sequence-stream

[constant] hamming-sequence-stream

Examples

(use streams)

(define (sigma function m n)
  (stream-fold + 0 (stream-map function (stream-range m (add1 n)))))

(define (factorial n)
  (stream-ref (stream-scan * 1 (stream-from 1)) n))

Usage

The exports of streams-primitive and streams-derived are povided by:

(require-extension streams)
 Or (a synonym)
(require-extension srfi-41)

Requirements

check-errors combinators record-variants

Author

Philip L. Bewig

Kon Lovett

Version history

1.2.4
Included inline-type-checks.scm so all includes are egg-local.
1.2.3
1.2.2
Check for stream type when forcing; reported by Jim Ursetto. Faster prime number stream; thanks to Matthias Bauer.
1.2.1
1.2.0
Use of record-variants & combinators.
1.1.0
Added "srfi-41" modules as synonynom of "streams".
1.0.2
Bug fix for problem w/ use of 'obj' in "streams-utils" reported by Josh Griffith. Better error message for nary stream procedures.
1.0.1
Updated test.
1.0.0
Chicken 4 release.

License

Copyright (C) 2007 by Philip L. Bewig of Saint Louis, Missouri, USA. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (C) 2009 Kon Lovett. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.