Le Thu, 01 Mar 2018, peter frey wrote: > utop # Vector.slice_seq (Vector.of_list [0;1;2;3;4]) 1 3 |> CCList.of_seq;; > - : int list = [1; 2; 3] > ─( 14:27:21 )─< command 41 >─────────────────────────────────────{ counter: > 0 }─
This is correct. > Same thing with length 5: > > utop # Vector.slice_seq (Vector.of_list [0;1;2;3;4]) 1 5 |> CCList.of_seq;; > Exception: Assert_failure ("src/core/CCVector.ml", 656, 4). This should fail (with a better error), because indexing starts at 0. Can you open an issue so I can track this better? :) (on github: go to c-cube/ocaml-containers, click "issues" then "open". Then add a title and, roughly, this message). If you prefer I can open an issue myself. > Source: > > let slice_seq v start len = > assert (start >= 0 && len >= 0); > fun k -> > assert (start+len < v.size); should be <= v.size ??? > for i = start to start+len-1 do > let x = Array.unsafe_get v.vec i in > k x > done > > with length 5 the slice is not a proper slice; but as with strings, a string > is a (not proper) sub_string of itself; so a slice of the whole vector would > also be expected to be a slice? Right, should be <= v.size indeed. An not an assertion, a check + invalid_arg. -- Simon Cruanes http://weusepgp.info/ key 49AA62B6, fingerprint 949F EB87 8F06 59C6 D7D3 7D8D 4AC0 1D08 49AA 62B6
signature.asc
Description: PGP signature
_______________________________________________ Containers-users mailing list Containers-users@lists.ocaml.org http://lists.ocaml.org/listinfo/containers-users