Closed favonia closed 10 months ago
I'm not sure this is a good idea... The purpose of Seq
, to my understanding, is to support compositional lazy list programming — but it seems neither (1) nor (2) benefits from this. As you say, (2) seems a little crazy without memoization, and (1) seems to offer very little benefit over List.to_seq (Bwd.to_list u)
.
You are right that the more reasonable option (1) is just List.to_seq (Bwd.to_list u)
. I think of_seq
makes a bit more sense but then it's strange to have of_seq
but not to_seq
.
I'm thinking about adding
to_seq
andof_seq
, but there seem to be two possible implementations ofto_seq
:Seq.t
takes O(n) time and then all further items take O(1) time.Seq.t
takes O(1) time but the first item can take O(n) time. Further items take O(1) time.I wonder what would be better? The concern about the second approach is that it can take O(n) time to retrieve the first item every time. One can also memoize it (maybe via
lazy
) but I'm not sure if it's worth it.