1. camlspotter
  2. spotlib

Commits

camlspotter  committed 5b47183

added Haskellish string sub (split_at, take, drop)

  • Participants
  • Parent commits 0759891
  • Branches default

Comments (0)

Files changed (2)

File lib/xstring.ml

View file
   let chop_newline = chop_newline
   let split_by_newline = split_by_newline
 end
+
+let split_at len str = String.sub str 0 len, String.sub str len (String.length str - len)
+let take len str = String.sub str 0 len
+let drop len str = String.sub str len (String.length str - len)

File lib/xstring.mli

View file
   val chop_newline : string -> string
   val split_by_newline : string -> string list
 end
+
+(** Haskelish string sub *)
+val split_at : int -> string -> string * string
+val take : int -> string -> string
+val drop : int -> string -> string