From 0a64b86c13d929c2fb9ad2a9c6646689ecf0bb2f Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Mon, 5 Feb 2018 19:15:34 +0100 Subject: [PATCH] typos/comments for bs_List --- jscomp/others/bs_List.mli | 160 ++++++++++++++++++++++++-------------- 1 file changed, 100 insertions(+), 60 deletions(-) diff --git a/jscomp/others/bs_List.mli b/jscomp/others/bs_List.mli index c6a808815d..188e7a9ff1 100644 --- a/jscomp/others/bs_List.mli +++ b/jscomp/others/bs_List.mli @@ -31,8 +31,12 @@ type 'a t = 'a list (** [t] is compatible with built-in [list] type *) val length: 'a t -> int +(** [length l] + return the length of the list [l] +*) + val size: 'a t -> int -(** [size l] is the same as [lenth l] *) +(** [size l] is the same as [length l] *) val head: 'a t -> 'a option @@ -43,74 +47,97 @@ val add: 'a t -> 'a -> 'a t val get: 'a t -> int -> 'a option (** [get xs n] - return the nth element in [xs] + return the nth element in [xs], + or [None] if [n] is larger than the length *) val getExn: 'a t -> int -> 'a (** [getExn xs n] - {b raise} an exception if [n] is larger than the length of list + return the nth element in [xs], + or {b raise} an exception if [n] is larger than the length *) val make: int -> 'a -> 'a t (** [make n v] - - return empty if [n] is negative - - return a list of length [n] filled with [v] + - return a list of length [n] with each element filled with [v] + - return the empty list if [n] is negative *) val makeByU: int -> (int -> 'a [@bs]) -> 'a t val makeBy: int -> (int -> 'a) -> 'a t (** [makeBy n f] - - return empty if [n] is negative - - return a list of length [n] filled with [f i] start from [0] to [n - 1] + - return a list of length [n] with element [i] initialized with [f i] + - return the empty list if [n] is negative *) - val drop: 'a t -> int -> 'a t option (** [drop xs n] - drop [n] elements from [xs] + return the list obtained by dropping the first [n] elements, + or [None] if [xs] has fewer than [n] elements *) + val take: 'a t -> int -> 'a t option (** [take xs n] - take [n] elements from [xs] + return a list with the first [n] elements from [xs], + or [None] if [xs] has fewer than [n] elements *) val splitAt: 'a t -> int -> ('a list * 'a list) option -(** [splitAt ls n] - - return None when the length of [ls] is less than [n] +(** + [splitAt xs n] + split the list [xs] at position [n] + return None when the length of [xs] is less than [n] *) val concat: 'a t -> 'a t -> 'a t +(** + [concat xs ys] + return the list obtained by adding [ys] after [xs] +*) val concatMany: 'a t array -> 'a t +(** + [concatMany a] + return the list obtained by concatenating in order all the lists in array [a] +*) val reverseConcat: 'a t -> 'a t -> 'a t (** - [reverseConcat a b] is equivalent to [concat (reverse a) b] + [reverseConcat xs ys] is equivalent to [concat (reverse xs) ys] *) val flatten: 'a t t -> 'a t +(** + [flatten ls] + return the list obtained by concatenating in order all the lists in list [ls] +*) val mapU: 'a t -> ('a -> 'b [@bs]) -> 'b t -val map: 'a t -> ('a -> 'b) -> 'b t +val map: 'a t -> ('a -> 'b) -> 'b t +(** + [map xs f] + return the list obtained by applying [f] to the element of [xs] +*) val zip: 'a t -> 'b t -> ('a * 'b) t (** [zip xs ys] - stops with shorter array + return a list of pairs from the two lists + with the length of the shorter list *) -val zipByU: 'a t -> 'b t -> ('a -> 'b -> 'c [@bs]) -> 'c t -val zipBy: 'a t -> 'b t -> ('a -> 'b -> 'c ) -> 'c t +val zipByU: 'a t -> 'b t -> ('a -> 'b -> 'c [@bs]) -> 'c t +val zipBy: 'a t -> 'b t -> ('a -> 'b -> 'c) -> 'c t (** [zipBy xs ys f] - stops with shorter array + + equivalent to [zip xs ys |> List.map (fun (x,y) -> f x y)] *) -val mapWithIndexU: 'a t -> (int -> 'a -> 'b [@bs]) -> 'b t -val mapWithIndex: 'a t -> (int -> 'a -> 'b ) -> 'b t +val mapWithIndexU: 'a t -> (int -> 'a -> 'b [@bs]) -> 'b t +val mapWithIndex: 'a t -> (int -> 'a -> 'b) -> 'b t val ofArray: 'a array -> 'a t @@ -126,25 +153,25 @@ val reverse: 'a t -> 'a t val mapReverseU: 'a t -> ('a -> 'b [@bs]) -> 'b t -val mapReverse: 'a t -> ('a -> 'b ) -> 'b t -(** [mapReverse a f] is equivalent to [reverse (map a f)] +val mapReverse: 'a t -> ('a -> 'b) -> 'b t +(** [mapReverse a f] is equivalent to [reverse (map a f)] *) -val forEachU: 'a t -> ('a -> 'b [@bs]) -> unit -val forEach: 'a t -> ('a -> 'b ) -> unit +val forEachU: 'a t -> ('a -> 'b [@bs]) -> unit +val forEach: 'a t -> ('a -> 'b) -> unit val forEachWithIndexU: 'a t -> (int -> 'a -> 'b [@bs]) -> unit val forEachWithIndex: 'a t -> (int -> 'a -> 'b) -> unit -val reduceU: 'a t -> 'b -> ('b -> 'a -> 'b [@bs]) ->'b -val reduce: 'a t -> 'b -> ('b -> 'a -> 'b) ->'b +val reduceU: 'a t -> 'b -> ('b -> 'a -> 'b [@bs]) -> 'b +val reduce: 'a t -> 'b -> ('b -> 'a -> 'b) -> 'b -val reduceReverseU: 'a t -> 'b -> ('a -> 'b -> 'b [@bs]) -> 'b -val reduceReverse: 'a t -> 'b -> ('a -> 'b -> 'b ) -> 'b +val reduceReverseU: 'a t -> 'b -> ('a -> 'b -> 'b [@bs]) -> 'b +val reduceReverse: 'a t -> 'b -> ('a -> 'b -> 'b) -> 'b -val mapReverse2U: 'a t -> 'b t -> ('a -> 'b -> 'c [@bs]) -> 'c t -val mapReverse2: 'a t -> 'b t -> ('a -> 'b -> 'c ) -> 'c t +val mapReverse2U: 'a t -> 'b t -> ('a -> 'b -> 'c [@bs]) -> 'c t +val mapReverse2: 'a t -> 'b t -> ('a -> 'b -> 'c) -> 'c t (** [mapReverse2 xs ys f] equivalent to [reverse (map2 xs ys f)] @@ -154,54 +181,58 @@ val mapReverse2: 'a t -> 'b t -> ('a -> 'b -> 'c ) -> 'c t ]} *) -val forEach2U: 'a t -> 'b t -> ('a -> 'b -> 'c [@bs]) -> unit -val forEach2: 'a t -> 'b t -> ('a -> 'b -> 'c ) -> unit +val forEach2U: 'a t -> 'b t -> ('a -> 'b -> 'c [@bs]) -> unit +val forEach2: 'a t -> 'b t -> ('a -> 'b -> 'c) -> unit (** [forEach2 xs ys f] stop with the shorter list *) val reduce2U: - 'b t -> 'c t -> 'a -> ('a -> 'b -> 'c -> 'a [@bs]) -> 'a + 'b t -> 'c t -> 'a -> ('a -> 'b -> 'c -> 'a [@bs]) -> 'a val reduce2: - 'b t -> 'c t -> 'a -> ('a -> 'b -> 'c -> 'a ) -> 'a + 'b t -> 'c t -> 'a -> ('a -> 'b -> 'c -> 'a) -> 'a (** [reduce2 xs ys init f ] stops with the shorter list. *) val reduceReverse2U: - 'a t -> 'b t -> 'c -> ('a -> 'b -> 'c -> 'c [@bs]) -> 'c + 'a t -> 'b t -> 'c -> ('a -> 'b -> 'c -> 'c [@bs]) -> 'c val reduceReverse2: - 'a t -> 'b t -> 'c -> ('a -> 'b -> 'c -> 'c ) -> 'c + 'a t -> 'b t -> 'c -> ('a -> 'b -> 'c -> 'c) -> 'c (** [reduceReverse2 xs ys init f ] Stops with the shorter list @example {[ - reduceReverse2 [1;2;3] [1;2] 0 (fun acc x y -> acc + x + y ) = 6 + reduceReverse2 [1;2;3] [1;2] 0 (fun acc x y -> acc + x + y) = 6 ]} *) -val everyU: 'a t -> ('a -> bool [@bs]) -> bool -val every: 'a t -> ('a -> bool ) -> bool +val everyU: 'a t -> ('a -> bool [@bs]) -> bool +val every: 'a t -> ('a -> bool) -> bool val someU: 'a t -> ('a -> bool [@bs]) -> bool -val some: 'a t -> ('a -> bool ) -> bool +val some: 'a t -> ('a -> bool) -> bool val every2U: 'a t -> 'b t -> ('a -> 'b -> bool [@bs]) -> bool -val every2: 'a t -> 'b t -> ('a -> 'b -> bool ) -> bool +val every2: 'a t -> 'b t -> ('a -> 'b -> bool) -> bool val cmpU: 'a t -> 'a t -> ('a -> 'a -> int [@bs]) -> int val cmp: 'a t -> 'a t -> ('a -> 'a -> int) -> int -(** @example {[ - cmp -]} +(** + [cmp xs ys cmp_elem] + compare lists [xs] and [ys] using [cmp_elem] to compare elements *) + val eqU: 'a t -> 'a t -> ('a -> 'a -> bool [@bs]) -> bool val eq: 'a t -> 'a t -> ('a -> 'a -> bool) -> bool (** + [eq xs ys eq_elem] + check equality of [xs] and [ys] using [eq_elem] for equality on elements + @example {[ eq [1;2;3] [1;2] (=) = false ;; eq [1;2] [1;2] (=) = true @@ -211,32 +242,38 @@ val eq: 'a t -> 'a t -> ('a -> 'a -> bool) -> bool val some2U: 'a t -> 'b t -> ('a -> 'b -> bool [@bs]) -> bool val some2: 'a t -> 'b t -> ('a -> 'b -> bool) -> bool -val hasU: 'a t -> 'b -> ('a -> 'b -> bool [@bs]) -> bool -val has: 'a t -> 'b -> ('a -> 'b -> bool) -> bool +val hasU: 'a t -> 'b -> ('a -> 'b -> bool [@bs]) -> bool +val has: 'a t -> 'b -> ('a -> 'b -> bool) -> bool -val getByU: 'a t -> ('a -> bool [@bs]) -> 'a option -val getBy: 'a t -> ('a -> bool) -> 'a option +val getByU: 'a t -> ('a -> bool [@bs]) -> 'a option +val getBy: 'a t -> ('a -> bool) -> 'a option -val keepU: 'a t -> ('a -> bool [@bs]) -> 'a t -val keep: 'a t -> ('a -> bool ) -> 'a t +val keepU: 'a t -> ('a -> bool [@bs]) -> 'a t +val keep: 'a t -> ('a -> bool) -> 'a t val keepMapU: 'a t -> ('a -> 'b option [@bs]) -> 'b t val keepMap: 'a t -> ('a -> 'b option) -> 'b t -val partitionU: 'a t -> ('a -> bool [@bs]) -> 'a t * 'a t -val partition: 'a t -> ('a -> bool) -> 'a t * 'a t +val partitionU: 'a t -> ('a -> bool [@bs]) -> 'a t * 'a t +val partition: 'a t -> ('a -> bool) -> 'a t * 'a t val unzip: ('a * 'b) t -> 'a t * 'b t -val assocU: ('a * 'c) t -> 'b -> ('a -> 'b -> bool [@bs]) -> 'c option -val assoc: ('a * 'c) t -> 'b -> ('a -> 'b -> bool) -> 'c option - - +val assocU: ('a * 'c) t -> 'b -> ('a -> 'b -> bool [@bs]) -> 'c option +val assoc: ('a * 'c) t -> 'b -> ('a -> 'b -> bool) -> 'c option +(** + [assoc xs x eq] + return the second element of a pair in [xs] where the first element equals [x], + or [None] if not found +*) val hasAssocU: ('a * 'c) t -> 'b -> ('a -> 'b -> bool [@bs]) -> bool -val hasAssoc: ('a * 'c) t -> 'b -> ('a -> 'b -> bool ) -> bool - +val hasAssoc: ('a * 'c) t -> 'b -> ('a -> 'b -> bool) -> bool +(** + [hasAssoc xs x eq] + return true if there is a pair in [xs] where the first element equals [x] +*) val removeAssocU: ('a * 'c) t -> @@ -246,7 +283,10 @@ val removeAssoc: ('a * 'c) t -> 'b -> ('a -> 'b -> bool) -> ('a * 'c) t - +(** + [removeAssoc xs x eq] + remove pairs from list [xs] where the first element equals [x] +*)