Hi all,
I'm just trying to write a recursive function that iterates¹ on a string
and I'd like to use pattern matching as in:
let rec iter f s =
match s with
| "" -> unit;
| c^s1 -> f c; iter f s1;;
but the ^ concatenates 2 strings and not a char with a string and above
all seems to be inadmissible in the patterns.
Does this mean that I can't write a function on strings by pattern
matching or is there something I don't know?²
Thanks for the help
Walter
¹ I know that exists String.iter but I'd like to improve my skill in
writing functions by using pattern matching
² I read about micmatch but I'd like to avoid non standard packages.
--
--
Caml-list mailing list. Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs