Hi everybody. I had been playing with sequences from the standard library, and the various data structures they can be converted to, when I found the curious following behaviour for Array.of_seq
:
# [1;2;3;4] |> List.to_seq |> List.of_seq;;
- : int list = [1; 2; 3; 4]
# [|1;2;3;4|] |> Array.to_seq |> Array.of_seq;;
- : int array = [|4; 1; 2; 3|]
# [|1;2;3;4|] |> Array.to_seq |> List.of_seq;;
- : int list = [1; 2; 3; 4]
# [1;2;3;4] |> List.to_seq |> Array.of_seq;;
- : int array = [|4; 1; 2; 3|]
Is this a bug, or is the rotation in the obtained array normal and to be expected ? In the latter case, may you tell me the reasons behind it ? The OCaml reference for the Array
module just states “Create an array from the generator” for the of_seq
function. There is no note explaining why this happens.
Thanks a lot for your answers.
— cloudyhug