spotlib / lib / xlist.mli

val iter_until : ('a -> [`Break of 'b | `Continue]) -> 'a list -> 'b option
val iteri : (int -> 'a -> 'b) -> 'a list -> unit
val mapi : (int -> 'a -> 'b) -> 'a list -> 'b list

val from_to : int -> int -> int list
  (** [from_to f t = [f..t]] *)

val (--) : int -> int -> int list
  (** [same as from_to. [f--t = [f..t]] ] *)

val init_from_to : int -> int -> (int -> 'a) -> 'a list
  (** [init_from_to f t fn = [fn x | x <- [f..t]] *)

val find_opt : ('a -> bool) -> 'a list -> 'a option
val find_map_opt : ('a -> 'b option) -> 'a list -> 'b option
val assoc_all : 'a -> ('a * 'b) list -> 'b list

val filter_map : ('a -> 'b option) -> 'a list -> 'b list
val concat_map : ('a -> 'b list) -> 'a list -> 'b list
(** concatMap of Haskell. bind for the list monad. Non tail rec *)

val take : int -> 'a list -> 'a list
val drop : int -> 'a list -> 'a list
val span : ('a -> bool) -> 'a list -> 'a list * 'a list
val partition : ('a -> bool) -> 'a list -> 'a list * 'a list
val partition_map : ('a -> 'b option) -> 'a list -> 'b list * 'a list
val split_at : int -> 'a list -> 'a list * 'a list
val unique : 'a list -> 'a list (** Haskell's nub *)

val is_unique : ('a -> 'b) -> 'a list -> ('a * 'a) option
  (** Check the list is a unique list or not, wrt the key function. 
      If not, it returns a dupe example. 
      
      [is_unique fst [(1,2); (2,3); (4,5)] = None]
      [is_unique fst [(1,2); (2,3); (2,5)] = Some ( (2,3), (2,5) ) ]
  *)

val intersperse : 'a -> 'a list -> 'a list

val last : 'a list -> 'a
  (** raises Failure when the argument is [].
      [last [1;2;3] = 3]
  *)

val scani_left : 
  (int -> 'a -> 'b -> [< `Continue of 'a | `Stop of 'a ]) 
  -> 'a -> 'b list -> 'a
  (** [foldl] but stoppable *)

module Infix : sig
  val (--) : int -> int -> int list
  (** [same as from_to. [f--t = [f..t]] ] *)
end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.