結果
問題 | No.400 鏡 |
ユーザー | r6eve |
提出日時 | 2017-08-14 13:35:14 |
言語 | OCaml (5.1.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 714 bytes |
コンパイル時間 | 83 ms |
コンパイル使用メモリ | 16,896 KB |
最終ジャッジ日時 | 2024-04-27 02:29:04 |
合計ジャッジ時間 | 387 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
File "Main.ml", line 8, characters 6-18: 8 | s.[i] <- f i ^^^^^^^^^^^^ Error: Syntax error: strings are immutable, there is no assignment syntax for them. Hint: Mutable sequences of bytes are available in the Bytes module. Hint: Did you mean to use 'Bytes.set'?
ソースコード
module String = struct include String (* @since 4.02.0 *) let init n f = let s = String.create n in for i = 0 to n - 1 do s.[i] <- f i done; s let rev str = let n = String.length str in init n (fun i -> str.[n - 1 - i]) let to_list str = let rec doit i acc = if i < 0 then acc else doit (i - 1) (String.get str i :: acc) in doit (String.length str - 1) [] let fold_left f init str = let n = String.length str - 1 in let rec doit i acc = if i > n then acc else doit (i + 1) (f acc str.[i]) in doit 0 init end let () = read_line () |> String.rev |> String.map (fun c -> if c = '<' then '>' else '<') |> print_endline