The code explains itself.
val s = Seq(1,1,1)
val res: Seq[Int] = s.map(...)
.check(count how many 1s, if > 2 throw Exception)
.map(...)
I am searching the simple solution to this check
function .
- I can use
map
andclosure
to count and throw, but I want pure function. - I can use
filter
andsize
orreduce
, but it return a value and not resumable with following maps.
How do I make a pure and stateful checking-pipe to the pipeline ?