View Problem

Capitalise the first letter of each word

Transform "man OF stEEL" into "Man Of Steel"
ExpandDiskEdit
ruby
caps = text.gsub(/\w+/) { $&.capitalize }
ExpandDiskEdit
ruby
caps = text.split.each{|i| i.capitalize!}.join(' ')
DiskEdit
ruby
text.split.map(&:capitalize) * ' '
DiskEdit
clojure
(use 'clojure.contrib.str-utils2)
(join " " (map capitalize (split "man OF stEEL" #" ")))
ExpandDiskEdit
cpp
std::string words = "mAn OF stEEL";
std::transform(words.begin(), words.end(), words.begin(), ToCaps<>());
ExpandDiskEdit
cpp C++/CLI .NET 2.0
StringBuilder^ sb = gcnew StringBuilder(L"man OF stEEL");

for (int i = 0, isFirst = 1; i < sb->Length; ++i)
{
sb[i] = Char::IsWhiteSpace(sb[i]) ? (isFirst = 1, sb[i]) : isFirst ? (isFirst = 0, Char::ToUpper(sb[i])) : Char::ToLower(sb[i]);
}
ExpandDiskEdit
cpp
std::string words = "mAn OF stEEL";
std::vector<std::string> swv;

boost::split(swv, words, boost::is_any_of(" "));
std::string newwords = (std::for_each(swv.begin(), swv.end(), StringTAndJ(WordToCaps))).value();

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