TzString: add fold_left
This commit is contained in:
parent
44b39a51c3
commit
2d349b606f
@ -73,3 +73,8 @@ let mem_char s c =
|
||||
match String.index s c with
|
||||
| exception Not_found -> false
|
||||
| _ -> true
|
||||
|
||||
let fold_left f init s =
|
||||
let acc = ref init in
|
||||
String.iter (fun c -> acc := f !acc c) s ;
|
||||
!acc
|
||||
|
@ -29,3 +29,6 @@ val common_prefix: string -> string -> int
|
||||
|
||||
(** Test whether a string contains a given character *)
|
||||
val mem_char: string -> char -> bool
|
||||
|
||||
(** Functional iteration over the characters of a string from first to last *)
|
||||
val fold_left : ('a -> char -> 'a) -> 'a -> string -> 'a
|
||||
|
Loading…
Reference in New Issue
Block a user