stream-stream-limit.nix
Source: /nix/store/mls72plk3raskl1r5afh3cl9ik3rn969-source/nix/stream-limit.nix
Module Description
Stream limiting operations - taking first n elements or while condition holds
Combinators
take
Takes first n elements from stream.
Terminates after n elements even if source continues. Enables working with infinite streams.
Type Signature
Int -> Stream<S, V> -> Stream<S, V>
Parameters
n: Number of elements to takestream: Source stream
Example
runFx (toList (take 2 (fromList [1 2 3 4])))
# => [1 2]
See Also
takeWhile- Take until conditionfilter- Conditional selection
takeWhile
Takes elements while predicate holds.
Terminates on first element that doesn’t match predicate.
Type Signature
(V -> Bool) -> Stream<S, V> -> Stream<S, V>
Parameters
pred: Predicate to teststream: Source stream
Example
runFx (toList (takeWhile (x: x < 3) (fromList [1 2 3 4])))
# => [1 2]
See Also
take- Take fixed numberfilter- Keep all matching
Generated from /nix/store/mls72plk3raskl1r5afh3cl9ik3rn969-source/nix/stream-limit.nix