各文字がアルファベットの大文字であるタイプ(char、 'list)リストのリストを作成したいと思います。私はget_listの2番目のマッチの場合、警告をWarning 11: this match case is unused.
にしています。私は最初のケースでいくつかのプリントを行い、len
が値0で取得されていることを発見したので、2番目のケースは使用しません。何が起こっていますか?OCamlで使用されない大文字小文字の区別
let rec get_list abc i len =
match i with
| len -> []
| _ -> ((String.get abc i), [])::get_list abc (i + 1) len
in
let rec print_list l =
match l with
| [] ->()
| h::t -> print_char(fst h);print_list t
in
let abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" in
let abc_l = get_list abc 0 (String.length abc) in
print_list abc_l;;
私はそれから...それ以外... '場合を使用したいです...'式の代わりに整数を使用しています。これは、読者の感覚をはるかに速く、エラーを起こしにくいものにします。 –