I would like to implement analog of Haskell cycle function.
cycle
If I pass list elements explicitly it seems trivial:
let cycle a b c = let rec
In an eager language like ML, you need to use streams. For example
# let cycle = Stream.from (fun n -> Some (List.nth [1;2;3] (n mod 3)));; val cycle : int Stream.t = # Stream.npeek 10 cycle;; - : int list = [1; 2; 3; 1; 2; 3; 1; 2; 3; 1]