Module BC_List


module BC_List: sig  end
An extention of the standard List module. Inherits all functions from List with a few more functions of our own.
Author(s): Hideo Bannai

val init : int -> (int -> 'a) -> 'a list
similar to Array.init.
val iteri : (int -> 'a -> unit) -> 'a list -> unit
similar to Array.iteri.
val map_to_array : ('a -> 'b) -> 'a list -> 'b array
map_to_array f lst is the same as Array.map f (Array.of_list lst) but doesn't create the intermediate array.
val uniq : 'a list -> 'a list
remove redundant consecutive elements of a list (similar to UNIX command uniq). not tail-recursive
val rev_uniq : 'a list -> 'a list
remove redundant consecutive elements of a list (similar to UNIX command uniq), but the result is in reverse order. tail-recursive
val uniq_base : 'a list -> ('a -> 'a -> int) -> 'a list
uniq_base lst comp removes redundant consecutive elements of a list using a comparator comp.
val group : ('a -> 'a -> int) -> 'a list -> 'a list list
group compare lst groups the list of elements into a list of lists, according to a compare function. The semantics of the compare function should be the same as for List.sort.
val count : ('a -> bool) -> 'a list -> int
count p lst counts elements in list lst which satisfy predicate p
val nhd : 'a list -> int -> 'a list
nhd lst n returns the first n elements of list lst. not-tail recursive
val rev_nhd : 'a list -> int -> 'a list
rev_nhd lst n returns the first n elements of list lst in reverse order. tail recursive
val m : ('a -> 'a -> int) -> 'a list -> 'a
m cmp l return the element of list l that is minimum, with respect to cmp. cmp x y should return 0 if x and y are equal, -1 if x < y and 1 otherwise.
Raises Invalid_argument for an empty list
val min : 'a list -> 'a
return the minimum element of a list. (minimum defined by Pervasives.min)
Raises Invalid_argument for an empty list.
val max : 'a list -> 'a
return the maximum element of a list. (maximum defined by Pervasives.max)
Raises Invalid_argument for an empty list
val arg_m : ('a -> 'b) -> ('b -> 'b -> int) -> 'a list -> 'a
arg_m cmp f l return the element (and value) which gives the minimum value for the result of applying f with respect to cmp where cmp x y should return 0 if x and y are equal, -1 if x < y and 1 otherwise.

Should be slightly more efficient than m (fun x y -> cmp (f x) (f y)) l because the # of times f is evaluated is kept minimal.
Raises Invalid_argument for an empty list

val arg_min : ('a -> 'b) -> 'a list -> 'a
return the element (and value) which gives the minimum value for the result of applying a function.
Raises Invalid_argument for an empty list
val arg_max : ('a -> 'b) -> 'a list -> 'a
return the element (and value) which gives the maximum value for the result of applying a function.
Raises Invalid_argument for an empty list
val diff : 'a list -> 'a list -> 'a list
diff lst1 lst2 returns new list containing all elements in lst1 but not in lst2.
val combination : 'a list -> int -> 'a list list
combination lst k generates all combinations consisting of k elements in lst, and return them as a list. The number of elements in lst is limited to 64. The order of elememnts in the returned list is the same as lst.


The following are functions of the standard List module. See the OCaml manual for documentation.


val length : 'a list -> int
val hd : 'a list -> 'a
val tl : 'a list -> 'a list
val nth : 'a list -> int -> 'a
val rev : 'a list -> 'a list
val append : 'a list -> 'a list -> 'a list
val rev_append : 'a list -> 'a list -> 'a list
val concat : 'a list list -> 'a list
val flatten : 'a list list -> 'a list
val iter : ('a -> unit) -> 'a list -> unit
val map : ('a -> 'b) -> 'a list -> 'b list
val rev_map : ('a -> 'b) -> 'a list -> 'b list
val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a
val fold_right : ('a -> 'b -> 'b) -> 'a list -> 'b -> 'b
val iter2 : ('a -> 'b -> unit) -> 'a list -> 'b list -> unit
val map2 : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
val rev_map2 : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
val fold_left2 : ('a -> 'b -> 'c -> 'a) -> 'a -> 'b list -> 'c list -> 'a
val fold_right2 : ('a -> 'b -> 'c -> 'c) -> 'a list -> 'b list -> 'c -> 'c
val for_all : ('a -> bool) -> 'a list -> bool
val exists : ('a -> bool) -> 'a list -> bool
val for_all2 : ('a -> 'b -> bool) -> 'a list -> 'b list -> bool
val exists2 : ('a -> 'b -> bool) -> 'a list -> 'b list -> bool
val mem : 'a -> 'a list -> bool
val memq : 'a -> 'a list -> bool
val find : ('a -> bool) -> 'a list -> 'a
val filter : ('a -> bool) -> 'a list -> 'a list
val find_all : ('a -> bool) -> 'a list -> 'a list
val partition : ('a -> bool) -> 'a list -> 'a list * 'a list
val assoc : 'a -> ('a * 'b) list -> 'b
val assq : 'a -> ('a * 'b) list -> 'b
val mem_assoc : 'a -> ('a * 'b) list -> bool
val mem_assq : 'a -> ('a * 'b) list -> bool
val remove_assoc : 'a -> ('a * 'b) list -> ('a * 'b) list
val remove_assq : 'a -> ('a * 'b) list -> ('a * 'b) list
val split : ('a * 'b) list -> 'a list * 'b list
val combine : 'a list -> 'b list -> ('a * 'b) list
val sort : ('a -> 'a -> int) -> 'a list -> 'a list
val stable_sort : ('a -> 'a -> int) -> 'a list -> 'a list