mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-09 12:45:34 -05:00
make some functions in CCFun and CCString depend on ocaml version
This commit is contained in:
parent
5c559c2099
commit
611086e6ab
4 changed files with 25 additions and 3 deletions
4
_oasis
4
_oasis
|
|
@ -8,7 +8,7 @@ LicenseFile: LICENSE
|
|||
Plugins: META (0.3), DevFiles (0.3)
|
||||
OCamlVersion: >= 4.00.1
|
||||
BuildTools: ocamlbuild
|
||||
AlphaFeatures: ocamlbuild_more_args, compiled_setup_ml
|
||||
AlphaFeatures: compiled_setup_ml
|
||||
|
||||
Synopsis: A modular standard library focused on data structures.
|
||||
Description:
|
||||
|
|
@ -49,7 +49,7 @@ Library "containers"
|
|||
CCKList, CCInt, CCBool, CCArray, CCOrd, CCIO,
|
||||
CCRandom, CCKTree, CCTrie, CCString, CCHashtbl,
|
||||
CCFlatHashtbl, CCSexp, CCMap
|
||||
BuildDepends: cppo
|
||||
XMETARequires: cppo
|
||||
FindlibName: containers
|
||||
|
||||
Library "containers_string"
|
||||
|
|
|
|||
|
|
@ -26,7 +26,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
(** {1 Basic Functions} *)
|
||||
|
||||
#if OCAML_MAJOR >= 4 && OCAML_MINOR >= 2
|
||||
|
||||
external (|>) : 'a -> ('a -> 'b) -> 'b = "%revapply"
|
||||
external (@@) : ('a -> 'b) -> 'a -> 'b = "%apply"
|
||||
|
||||
#else
|
||||
|
||||
let (|>) x f = f x
|
||||
let (@@) f x = f x
|
||||
|
||||
#endif
|
||||
|
||||
let compose f g x = g (f x)
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
(** {1 Basic Functions} *)
|
||||
|
||||
val (|>) : 'a -> ('a -> 'b) -> 'b
|
||||
(** Pipeline (naive implementation) *)
|
||||
(** Pipeline. [x |> f] is the same as [f x]. *)
|
||||
|
||||
val compose : ('a -> 'b) -> ('b -> 'c) -> 'a -> 'c
|
||||
(** Composition *)
|
||||
|
|
@ -35,6 +35,10 @@ val compose : ('a -> 'b) -> ('b -> 'c) -> 'a -> 'c
|
|||
val (%>) : ('a -> 'b) -> ('b -> 'c) -> 'a -> 'c
|
||||
(** Alias to [compose] *)
|
||||
|
||||
val (@@) : ('a -> 'b) -> 'a -> 'b
|
||||
(** [f @@ x] is the same as [f x], but right-associative.
|
||||
@since NEXT_RELEASE *)
|
||||
|
||||
val id : 'a -> 'a
|
||||
(** Identity function *)
|
||||
|
||||
|
|
|
|||
|
|
@ -55,11 +55,19 @@ let compare = String.compare
|
|||
|
||||
let hash s = Hashtbl.hash s
|
||||
|
||||
#if OCAML_MAJOR >= 4 && OCAML_MINOR >= 2
|
||||
|
||||
let init = String.init
|
||||
|
||||
#else
|
||||
|
||||
let init n f =
|
||||
let buf = Buffer.create n in
|
||||
for i = 0 to n-1 do Buffer.add_char buf (f i) done;
|
||||
Buffer.contents buf
|
||||
|
||||
#endif
|
||||
|
||||
let length = String.length
|
||||
|
||||
let rec _to_list s acc i len =
|
||||
Loading…
Add table
Reference in a new issue