diff options
author | Masaya Tojo <masaya@tojo.tokyo> | 2024-06-16 12:15:11 +0900 |
---|---|---|
committer | Masaya Tojo <masaya@tojo.tokyo> | 2024-06-16 12:15:11 +0900 |
commit | e51a5f32bb8f23eb0fd27213cb36ce09a42a6386 (patch) | |
tree | 3c4d043a91d56fff6e7d59e3ed829dbeee0dbe26 /algebraic-structures.private.stream.applicative.scm | |
parent | a0ed10aa2a780894c8f63bd4bde218d56eba411e (diff) |
Add stream implementations
Diffstat (limited to 'algebraic-structures.private.stream.applicative.scm')
-rw-r--r-- | algebraic-structures.private.stream.applicative.scm | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/algebraic-structures.private.stream.applicative.scm b/algebraic-structures.private.stream.applicative.scm new file mode 100644 index 0000000..0389ad9 --- /dev/null +++ b/algebraic-structures.private.stream.applicative.scm @@ -0,0 +1,17 @@ +(module (algebraic-structures private stream applicative) () + (import scheme + (srfi 41) + (only (chicken base) cute) + (chicken module)) + (export pure map2) + (reexport (algebraic-structures stream functor)) + + (define (pure x) (stream x)) + + (define-stream (product op s1 s2) + (if (stream-null? s1) + stream-null + (stream-append (stream-map (cute op (stream-car s1) <>) s2) + (product op (stream-cdr s1) s2)))) + + (define map2 product)) |