Commits

Dmitry Grebeniuk  committed d1c0b0c

String: +for_all

  • Participants
  • Parent commits 31c7775

Comments (0)

Files changed (1)

File src/cd_Strings.ml

                           ~len:int -> string;
 
         value replace_char : char -> char -> string -> string;
+        value for_all : (char -> bool) -> string -> bool;
 
         include TFUNCS;
 
               str
         ;
 
+        exception For_all;
+
+        value for_all pred s =
+          try begin
+            for i = 0 to String.length s - 1 do
+              if pred s.[i]
+              then ()
+              else raise For_all
+            done;
+            True
+          end
+          with [ For_all -> False ]
+        ;
+
         include TCommon;
 
       end