Last active
August 29, 2015 14:13
-
-
Save st98/dbc4d215fd988d7872d5 to your computer and use it in GitHub Desktop.
OCaml 入門。Python の str.swapcase() みたいな。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let swapcase c = match c with | |
| 'A' .. 'Z' -> Char.lowercase c | |
| 'a' .. 'z' -> Char.uppercase c | |
| _ -> c | |
let swapcase_s s = String.map swapcase s;; | |
swapcase_s "AbC";; (* => "aBc" *) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment