You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Brian Cavalier edited this page Jun 17, 2016
·
4 revisions
Repeat the behavior of a stream N times.
import{empty,continueWith}from'most'// repeat :: number -> Stream a -> Stream a// return a stream that repeats the behavior of the input// stream n times. n must be >= 0. When n === 0, the returned// stream will be empty. When n === 1, the returned stream will// be indistinguishable from the input stream.constrepeat=(n,stream)=>n<=0 ? empty()
: n===1 ? stream
: continueWith(()=>repeat(n-1,stream),stream)