Skip to content

Commit

Permalink
Fixed length type.
Browse files Browse the repository at this point in the history
  • Loading branch information
rizo committed Dec 4, 2015
1 parent 4944628 commit 867ea0c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/IO_iter.ml
Expand Up @@ -92,7 +92,7 @@ let head p =
| None -> None

let sum source = fold ~init:0 ~f:(+) source
let len source = fold ~init:0 ~f:(fun c i -> c + 1) source
let length source = fold ~init:0 ~f:(fun c _ -> c + 1) source

let rec any source =
match next source with
Expand Down
2 changes: 1 addition & 1 deletion src/IO_iter.mli
Expand Up @@ -16,7 +16,7 @@ val fold : init:'a -> f:('a -> 'b -> 'a) -> ('c, 'b, 'd) node -> 'a
val head : (void, 'b, 'r) node -> 'b option
val iota : int -> (void, int, unit) node
val last : (void, 'b, 'r) node -> 'b option
val len : (void, int, 'r) node -> int
val length : (void, 'b, 'r) node -> int
val list : 'a list -> (void, 'a, unit) node
val map : ('a -> 'b) -> ('a, 'b, 'r) node
val nth : int -> ('a, 'b, 'r) node -> 'b option
Expand Down
4 changes: 2 additions & 2 deletions tests/test_io_iter.ml
Expand Up @@ -5,7 +5,7 @@ open IO.Iter

let test_sinks () = begin
print_endline "io_iter: test_sinks";
assert (len (iota 10) = 10);
assert (length (iota 10) = 10);
assert (sum (iota 10) = 45);
assert (last (range 20 26) = Some 25);
end
Expand All @@ -23,7 +23,7 @@ let test_api () = begin

assert (fold ~init:0 ~f:(+) (iota 1000000 => filter odd) = 250000000000);
assert (collect (count => take 5) = [0; 1; 2; 3; 4]);
assert (len (list (List.range 10 100) => take 10 => tail) = 9);
assert (length (list (List.range 10 100) => take 10 => tail) = 9);
assert (sum (list (List.range 10 100) => take 10 => filter even) = 70);
assert (fold ~init:0 ~f:(+) (list (List.range 50 100) => take 10) = 545);
assert (head (range 10 100) = Some 10);
Expand Down

0 comments on commit 867ea0c

Please sign in to comment.