|(require stream-etc)||package: stream-etc|
This library is experimental; compatibility may not be maintained.
> (define (parity=? x y) (= (modulo x 2) (modulo y 2))) > (stream-group-by '("1" "2" "3" "4") string->number parity=?)
'(("1" "3") ("2" "4"))
Forms that provide functionality akin to that of the Threading Macros library, only specialized to stream predicates.
(stream~> stream-expr clause ...)
clause = clause-expr | #:take clause-expr | #:repeat clause-expr = (fn-expr pre-expr ... hole-marker post-expr ...) | bare-expr hole-marker = _
An expression without a keyword should evaluate to a predicate that will be given the current prefix of the stream (starting off empty). If it’s ever #false, the entire stream~> will be #false.
A #:take clause expects a function that returns some prefix of the current stream and sets it as the current prefix of interest. The suffix then becomes the current stream. If the current stream is empty, the entire stream~> will become #true.
A #:repeat clause starts processing over from the first clause using the current stream.