View Problem

Capitalise the first letter of each word

Transform "man OF stEEL" into "Man Of Steel"
DiskEdit
python
from string import capwords
capwords("man OF stEEL")
DiskEdit
python 2.4
' '.join(s.capitalize() for s in "man OF stEEL".split())
DiskEdit
python
"man OF stEEL".title()
DiskEdit
csharp
System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase("man OF stEEL".ToLowerInvariant());
ExpandDiskEdit
fantom
"man OF stEEL".split.map { it.localeLower.localeCapitalize }.join(" ")
ExpandDiskEdit
fsharp
let words = String.Join(" ", Array.map (fun (s : String) -> (String.capitalize (s.ToLower()))) ("man OF stEEL".Split [|' '|]))
ExpandDiskEdit
fsharp
let wordlst = List.map (fun s -> (String.capitalize (String.lowercase s))) (String.split [' '] "man OF stEEL")
let words = new StringBuilder(List.hd wordlst)
for (s : String) in (List.tl wordlst) do (words.Append(" ").Append(s))
DiskEdit
fsharp 2.0
// Previous solutions used old library functions, here's something that works with F# 2.0
let s= "man OF stEEL"
let UpperFirst = function | "" -> "" | s -> s.Substring(0,1).ToUpper() + s.Substring(1).ToLower()
s.Split(' ') |> Array.map UpperFirst |> String.concat " "
ExpandDiskEdit
fsharp
let culture = System.Globalization.CultureInfo.GetCultureInfo("en-US")
let titleCase = culture.TextInfo.ToTitleCase "man oF sTeel"

Submit a new solution for python, csharp, fantom, or fsharp
There are 25 other solutions in additional languages (clojure, cpp, erlang, go ...)