LL Golf Hole 2 - 文字列に含まれる単語の最初の文字を大文字にする
Posted feedbacks - XSLT
XSLTもGolfには向きませんね。 本当は改行も全部消したかったんですが、 表示がエライことになるので止めました。 入力は↓のコード自身です。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <x:transform version="2.0"
xmlns:x="http://www.w3.org/1999/XSL/Transform"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:f="http://www.w3.org/2005/xpath-functions">
<x:variable name="ll2008" as="s:string">LL future</x:variable>
<x:variable name="ll2005" as="s:string">LL day and night</x:variable>
<x:output method="text"/>
<x:template match="/">
<x:apply-templates select="/x:transform/x:variable"/>
</x:template>
<x:template match="x:variable">
<x:variable name="tokens" as="s:string*">
<x:for-each select="f:tokenize(./text(),' ')">
<x:sequence select="f:concat(f:upper-case(f:substring(.,1,1)),f:substring(.,2,f:string-length(.)-1))"/>
</x:for-each>
</x:variable>
<x:value-of select="f:concat(@name,'=')"/>
<x:value-of select="string-join($tokens,' ')"/>
<x:text>
</x:text>
</x:template>
</x:transform>
|

takano32
#6901()
[
Ruby
]
Rating2/10=0.20
文字列に含まれる単語について、それぞれの単語の最初の文字を大文字にしてください。
たとえば、"LL future" と与えられたときは "LL Future" と出力する。"LL day and night" と与えられたときは "LL Day And Night" と出力する。
与えられる文字列はリテラルで表記する、標準入力で与えられる、引数で与えられるなどは自由とします。
余力のあるものはこのプログラムを短くしてみたり、短くしてみたり、短くしてください。
※LL Future実行委員の高野光弘です。この出題は LL Future公式の出題であり、優れたものについてはLL Golfのセッションでご紹介させていただくかもしれません。ご理解の上、ご投稿ください。また、LL Futureのチケットは現在も発売中です。よろしければ、メインイベントの方にもぜひご参加ください。
see: LL Golf
Rating2/10=0.20-0+
[ reply ]