Module Unprime_list.List
include module type of Stdlib.List
val length : 'a list -> intval compare_lengths : 'a list -> 'b list -> intval compare_length_with : 'a list -> int -> intval cons : 'a -> 'a list -> 'a listval hd : 'a list -> 'aval tl : 'a list -> 'a listval nth : 'a list -> int -> 'aval nth_opt : 'a list -> int -> 'a optionval rev : 'a list -> 'a listval init : int -> (int -> 'a) -> 'a listval append : 'a list -> 'a list -> 'a listval rev_append : 'a list -> 'a list -> 'a listval concat : 'a list list -> 'a listval flatten : 'a list list -> 'a listval iter : ('a -> unit) -> 'a list -> unitval iteri : (int -> 'a -> unit) -> 'a list -> unitval map : ('a -> 'b) -> 'a list -> 'b listval mapi : (int -> 'a -> 'b) -> 'a list -> 'b listval rev_map : ('a -> 'b) -> 'a list -> 'b listval filter_map : ('a -> 'b option) -> 'a list -> 'b listval fold_left : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'aval fold_right : ('a -> 'b -> 'b) -> 'a list -> 'b -> 'bval iter2 : ('a -> 'b -> unit) -> 'a list -> 'b list -> unitval map2 : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c listval rev_map2 : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c listval fold_left2 : ('a -> 'b -> 'c -> 'a) -> 'a -> 'b list -> 'c list -> 'aval fold_right2 : ('a -> 'b -> 'c -> 'c) -> 'a list -> 'b list -> 'c -> 'cval for_all : ('a -> bool) -> 'a list -> boolval exists : ('a -> bool) -> 'a list -> boolval for_all2 : ('a -> 'b -> bool) -> 'a list -> 'b list -> boolval exists2 : ('a -> 'b -> bool) -> 'a list -> 'b list -> boolval mem : 'a -> 'a list -> boolval memq : 'a -> 'a list -> boolval find : ('a -> bool) -> 'a list -> 'aval find_opt : ('a -> bool) -> 'a list -> 'a optionval filter : ('a -> bool) -> 'a list -> 'a listval find_all : ('a -> bool) -> 'a list -> 'a listval partition : ('a -> bool) -> 'a list -> 'a list * 'a listval assoc : 'a -> ('a * 'b) list -> 'bval assoc_opt : 'a -> ('a * 'b) list -> 'b optionval assq : 'a -> ('a * 'b) list -> 'bval assq_opt : 'a -> ('a * 'b) list -> 'b optionval mem_assoc : 'a -> ('a * 'b) list -> boolval mem_assq : 'a -> ('a * 'b) list -> boolval remove_assoc : 'a -> ('a * 'b) list -> ('a * 'b) listval remove_assq : 'a -> ('a * 'b) list -> ('a * 'b) listval split : ('a * 'b) list -> 'a list * 'b listval combine : 'a list -> 'b list -> ('a * 'b) listval sort : ('a -> 'a -> int) -> 'a list -> 'a listval stable_sort : ('a -> 'a -> int) -> 'a list -> 'a listval fast_sort : ('a -> 'a -> int) -> 'a list -> 'a listval sort_uniq : ('a -> 'a -> int) -> 'a list -> 'a listval merge : ('a -> 'a -> int) -> 'a list -> 'a list -> 'a listval to_seq : 'a list -> 'a Stdlib.Seq.tval of_seq : 'a Stdlib.Seq.t -> 'a list
include module type of Prime_list
val count : ('a -> bool) -> 'a list -> intcount f xsis the number of elementsxofxsfor whichf xholds.
val search : ('a -> 'b option) -> 'a list -> 'b optionsearch f xsreturns the first element ofmap f xswhich is different fromNoneorNoneif all elements areNone. This is an alternative tofindwhich is easy to nest, e.g. the functionPrime_array.search (Prime_option.search (Prime_list.search f))returns the first non-Nonemapping offin an array of optional lists.
Comparison
Iteration
val fold : ('a -> 'b -> 'b) -> 'a list -> 'b -> 'bfold f [x₁; …; xₙ]returns the compositionf xₙ ∘ ⋯ ∘ f x₁. This isfold_leftwith parameters reordered to make it more composable.
val fmap : ('a -> 'b option) -> 'a list -> 'b listval filter_map : ('a -> 'b option) -> 'a list -> 'b listfilter_map f xsis the list of allysuch thatf x = Some yfor somexinxs, and having the same order as the corresponding elemets ofxs. This provides an optimisation ofmap Option.get (filter ((<>) None) (map f xs)).
Iteration over Two Lists
val iter2t : ('a -> 'b -> unit) -> 'a list -> 'b list -> unititer2t f [x₁; …; xₙ] [y₁; …; yₘ]callsf x₁ y₁; …; f xₗ yₗin order, wherel = min n m. This is a truncating variant ofiter2from the standard library.
val map2t : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c listmap2t f [x₁; …; xₙ] [y₁; …; yₘ]returns[f x₁ y₁; ⋯; f xₗ yₗ]wherel = min n m. Thetsuffix indicates truncation, otherwise this behaves likemap2from the standard library.
val rev_map2t : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c listrev_map2t fis an optimisation ofrev ∘ map2t f.
Differential Iteration
Sublists
val drop : int -> 'a list -> 'a listdrop n xsreturns the suffix ofxsfollowing thenfirst elements. RaisesFailureifxsis shorter thannelements and Invalid_argument ifnis negative.
val take : int -> 'a list -> 'a listtake n xsreturns then-element prefix ofxs. RaisesFailureifxsis shorter thannelements and Invalid_argument ifnis negative.