2009-10-01から1ヶ月間の記事一覧
sprintfっぽい物を先頭に書いておくと、けっこう便利。 function sprintf() { // limited implementation of sprintf. var format = arguments[0], argv = arguments, i = 1; return format.replace(/%([s%])/g, function (all, type) { return type == "%" …
Selectors APIのDraftに、matchesSelectorというAPIが定義されていて、現在、WebKitとMinefieldのNightlyに搭載されている。 ただし、ドラフトなのでベンダープレフィックスがついていて、Element#webkitMatchesSelectorやElement#mozMatchesSelectorを使わ…
CSS Transitionsと呼ばれる機能で、CSSでアニメーションとかを実現する物。Safariには前からあった。 <style> body { -moz-transition: 5s all linear 0s; -webkit-transition: 5s all linear 0s; transition: 5s all linear 0s; text-align: center; text-shadow: </style>…
isSorted :: (Ord a) => [a] -> Bool isSorted [] = True isSorted [_] = True isSorted l = and $ zipWith (<) l (tail l) こんな感じに書ける。最近、zipやzipWith、mapといった基本的な高階関数が最初から(もしくは、builtinのモジュールとして)存在し…