ときどきの雑記帖 ぴゅあ

最新ページへのリンク
目次ページへのリンク

一つ前へ 2011年11月(下旬)
一つ後へ 2011年12月(中旬)

ホームへ

2011年12月09日

■_

なんかまた安売りが。 種類はそれほどでもないけど、いくつか欲しいのがあるなあ。 7 Weeks of Gift Ideas | Week 5 - Sift... Stir... Code. Cookbooks for Geeks - O'Reilly Media

■_ 被っても泣かない

bash TickTick: シェルでJSONを使えるようにするというアイデア - karasuyamatenguの日記

Imagine a world where Bash supports JSON. : programming


#!/bin/bash
	``
	  people = {
	    "Writers": [
	      "Rod Serling",
	      "Charles Beaumont",
	      "Richard Matheson"
	    ],
	    "Cast": {
	      "Rod Serling": { "Episodes": 156 },
	      "Martin Landau": { "Episodes": 2 },
	      "William Shatner": { "Episodes": 2 }
	    }
	  }
	``
	 
	function printDirectors() {
	  echo "  The ``people.Directors.length()`` Directors are:"
	 
	  for director in ``people.Directors.items()``; do
	    printf "    - %s\n" ${!director}
	  done
	}
	 
	`` people.Directors = [ "John Brahm", "Douglas Heyes" ] ``
	printDirectors
	 
	newDirector="Lamont Johnson"
	`` people.Directors.push($newDirector) ``
	printDirectors
	 
	echo "Shifted: ``people.Directors.shift()``"
	printDirectors
	 
	echo "Popped: ``people.Directors.pop()``"
	printDirectors

連続バッククォートが目印なんだろうか。

■_

neko.com じゃなかろうか。 某雑誌のライターがウイルス扱いして恥かいたという。 Neko (ソフトウェア) - Wikipedia

cat コマンドでネコを走らせる - hogehoge @teramako

ぬこ 2011/12/08 10:04 PC98 が全盛の時代に CAT.EXE だか
アニメーションする猫が常駐する
有名なフリーソフトがあったのを思い出しました

■_ ベーダー卿は

すばらしいプロジェクトマネージャーらしい

Top 10 reasons why Darth Vader was an amazing project manager - GeekWire

Top 10 reasons why Darth Vader was an amazing project manager
October 4, 2011 at 1:40 pm by Brandon Koeller 73 Comments

The Sith Lord Darth Vader, of Star Wars fame, often gets a bad rap, particularly in what
we all think of as his ‘dark years.'

From a certain perspective his mass murder, brutal oppression, and frequent deception to
serve his own ends makes him seem like a pretty bad guy. But if you look past all that
to his action, you will find a very capable and effective project manager.

しかし過去の彼の行動を振り返ってみれば、そこに very capable で effective な
プロジェクトマネージャーがいることに気がつくでしょう。

In the name of finding silver linings in dark clouds, I'd like to present the top 10 
reasons why Darth Vader was an amazing project manager.

ベーダー卿が驚嘆すべきプロジェクトマネージャーであったことの十個の理由をお見せしましょう


Number 10: Vader prioritized brutally. Over the course of Vader's pursuit of the Rebel
Alliance, you see him set and pursue priorities according to their strategic value. When
he knew the plans for the Death Star had been leaked, he focused on mitigating that risk.
When Luke came on the scene, he shifted priorities to recruit him to the Dark Side! Vader
paid close attention to the happenings of the galaxy, evaluated the impacts of any given
issue, and went after the highest priorities…time after time. No emotional attachments,
no personal agendas…just the right thing to do to preserve the Imperium, and see his
project through to successful completion. In project management, if you can't prioritize,
you won't get anything done, let alone anything done well.

ベーダーは獣のように(?)優先順位付けを行いました。


Number 9: Vader made decisions based on objective data, not whims.
          ベーダーは気まぐれにではなく、objective data に基づいて意思決定をしました
(略)

Number 8: Vader made commitments, and worked hard to keep them.
          ベーダーはコミットメントを行い、それを保つためにハードワークしました
(略)

Number 7: Vader took time to re-charge, relax, and get some perspective.
(略)

Number 6: Vader managed risk and expectations…pre-emptively.
(略)

Number 5: Such a persuasive fellow. Of all Vader's substantial capabilities, perhaps 
his most effective one was his ability to persuade people to do what he needed done. 
(略)

Number 4: Vader picked a methodology and stuck with it…until it didn't work.
(略)

Number 3: No problem is too big to tackle.
(略)

Number 2: It is never too late to do the right thing.
          正しいことを手遅れになることなく行った
(略)

Number 1: Vader was never afraid of getting his hands dirty.
          ベーダーは己の手を汚すことを恐れなかった
(略)


Copyright © 2011 · News Theme · Genesis Framework by StudioPress · WordPress · Log in

■_ Perl 6

adventから。

2.pod

はじめに

Perl6 Advent Calendar 2011(atnd.org)の9日の記事です。

前回では基本的な正規表現を扱いましたので、 そろそろ他の言語がついてこられなくなるような機能を
紹介したいと思います。

残念ながらここで紹介されていることの一部は、Rakudoでは動かないです。Nieczaを用意してください。

(略)

Longest token matching
Rakudoは無理。
(略)

選択のバックトラック削除
Rakudoは無理。

(略)
LTMのバックトラック削除
Rakudoは無理。

(略)
さらなる選択ポイントの削除
Rakudoは無理。

意外に未実装のがあった。>らくど

■_

■_

おもしろいコピペがあったら貼るスレinマ板part28 

125 仕様書無しさん [sage] 2011/12/08(木) 00:49:49.38 ID: Be:
    455 水先案名無い人 [sage] 2011/12/07(水) 09:38:59.61 ID:lBDyaTw00 Be:
          いいかみんな
            (゚д゚ )
            (| y |)

        片付けが出来ない人の部屋を片付けたりすると
            ( ゚д゚)  ||||||||||||||||||||||||||||||||||||||||||||_____________
            (\/\/

        新たに物を溜め込むスペースを作ってあげただけになったりする
            ( ゚д゚)  ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
            (\/\/

        要らない物を処分することは大事だぞ!    
            (゚д゚ )
            (| y |)

    456 水先案名無い人 [sage] 2011/12/07(水) 15:42:15.55 ID:xcY5IaRF0 Be:
    >>455
    ギクッ(゚.゚; 

2011年12月08日

■_

買った。

十字軍物語 3
三巻目は厚かった。って第三回十字軍から第七回まで、そして最後までだからなあ。 表紙絵を1、2, 3 と見比べると 十字軍物語〈1〉 十字軍物語2

こいつも。
ちぇんごく(下) (KCデラックス)

■_ 十の

あーMathematicaいぢりてー

Wolfram Blog : 10 Tips for Writing Fast Mathematica Code

10 Tips for Writing Fast Mathematica Code

December 7, 2011

Jon McLoone, International Business & Strategic Development

When people tell me that Mathematica isn't fast enough, I usually ask to see the offending
code and often find that the problem isn't a lack in Mathematica's performance, but
sub-optimal use of Mathematica. I thought I would share the list of things that I look for
first when trying to optimize Mathematica code.

■_ くいず

そいや Ruby でも以前やってましたね(まだやってる?)

Python Quiz of the Week - #1 : Python

I was given this problem in an interview a while back, I thought it was a good one. It 
might be a bit hard for a new programmer but fairly straightforward for
intermediate/expert level folks:

Find the longest words in a dictionary of legal words that can be constructed from a 
given list of letters.

与えられた文字のリストから構築可能な legal words の辞書の中で最も長い単語を見つけ出す

Your solution should take as its first argument the name of a dictionary file, which 
will be plain text with one word per line. The remaining arguments define the list of 
legal letters.

Note that each letter may be used only as many times as it occurs in the list of legal letters.

それぞれの文字は legal letters のリストに表れた回数だけ使うことが許される


Here's an example of how it should work:
使用例

  scrabble.py ospd.txt i g h l p r a ['argil', 'glair', 'grail', 'graph', 'hilar', 'laigh', 'phial', 'pilar', 'ralph']

I'm using the scrabble dictionary I found here: 
  http://www.puzzlers.org/pub/wordlists/ospd.txt

NOTE: at first I thought it might be a good idea to post the quiz first and make that 
page just for questions/ideas and then follow up later on with a solutions post. That 
way it would be easy to read the problem and questions without accidentally seeing any 
spoilers for possible solutions. But then I realized people would probably just post 
solutions wherever they wanted anyway. So here's the first problem. Don't go crazy 
trying to solve it instantaneously, it's not a race. Well, at least I'm not viewing it 
as a race.

I'm thinking the discussions these quizzes will generate will be about the style, 
readability, elegance and Pythonicityof the solutions. To be honest, I generally 
prefer r/Python to StackOverflow. I'm really interested in hearing how other Python 
redditors go about solving problems.

I suppose that if this really takes off, it could be its own subreddit. . .

Anyway, here's the first problem.

EDIT: wow, a lot of responses. This is great. I think going forward, we should post 
solutions to gist.github.com (or an equivalent) as sixthgear did. I'm back at work now 
but I'll check back on this later today. Comment or message me on ideas for the next 
quiz. . .

■_

■_

茄子

■_

Applicative よくわかりません。 某方面でよく見かける単語なんですが。

Applicatives are generalized functors | Heiko's Blog
Applicatives are generalized functors
Posted on 2011-01-31

In my previous blog post about categories and functors I already threatened you with 
the possibility of a follow-up. Well, here we go. Actually I won't talk about 
category theory this time, but about an important abstraction from the world of 
advanced (at least in my understanding) functional programming which turns out to be a 
close relative to the now well understood functor.

2011年12月07日

■_

十字軍物語3が出るというお知らせメールが来た。 発売日は9日なんだけど、一部の書店ではすでに入ってきていたらしい。

■_

■_

glob.glob って、ワイルドカードの展開結果をリストにして返すので、 hoge.py a*.txt b*.txt なんてやったときに [[a1.txt, a2.txt], [b1.txt, b2.txt, b3.txt]] みたいな感じになるんですが、 これを flattern するのって一回リストにしないとだめなんですかね。 ジェネレーターのまんまとりだせないかなーなどと。

import sys
import json
import glob
import itertools

def flatten(listOfLists):
   "Flatten one level of nesting"
   return itertools.chain.from_iterable(listOfLists)

for infile in flatten(glob.glob(x) for x in sys.argv[1:]):
   print(infile)
   fi = open(infile)
   for e in fi:
       entry = json.loads(e)
       print(entry['created_at'])
   fi.close()

↑の flattern は itertools の解説ページから持ってきたもの。

■_ love

Why I Love to Code « thecodergirl

December 7, 2011
Why I Love to Code

I'm a passionate person, pouring my heart and soul into everything I do, including my 
profession as a software developer. I don't just sit around and write IF statements 
and loops all day (like we did in college), or SELECT statements, or lame SVN commit 
messages (although sometimes those slip out when I'm not looking). I'm not in this for 
the money, prestige, or political power.

For me, it's about the thrill of the chase.


■_ Firefox でクリップボードをごにょごにょ

いろいろあって、今三種類を一度に使ってたりするんですが 二つは対応バージョンはかなり前までのをごまかして使ってて、 最後のひとつは動作が今ひとつ気に入らない。

makelink/chrome/content/makelink/makelink.js
   var clip = Components.classes['@mozilla.org/widget/clipboard;1']
       .createInstance(Components.interfaces.nsIClipboard);

makelink/chrome/content/makelink/link_maker.js
 var clipboard = Components.classes['@mozilla.org/widget/clipboard;1']
     .getService(Components.interfaces.nsIClipboard);

copyurl/chrome/content/copyurlplus/copyurlplusOverlay.js
       var clipid=Components.interfaces.nsIClipboard;
       var clip = Components.classes["@mozilla.org/widget/clipboard;1"].getService(clipid);

firelink/resources/jid0-seifaydckhvdzhihlua8wnsduu4-addon-kit-lib/clipboard.js
let clipboardService = Cc["@mozilla.org/widget/clipboard;1"].
                      getService(Ci.nsIClipboard);

let clipboardHelper = Cc["@mozilla.org/widget/clipboardhelper;1"].
                     getService(Ci.nsIClipboardHelper);

クリップボードからデータを取ってくるの自体は基本的に同じみたいですねえ。

2011年12月06日

■_

PowerSherll で JSON データをごにょごにょする手段はあるらしい PowerShellでJScript.NETを利用してJSONをパースする - PowerShell Scripting Weblog

■_ flip-flop

最後の方にもっと面白いことが書いてあったのを見落としていた(^^;

The Flip-Flop operator « Perl 6 Advent Calendar

    for 1..20 { .say if $_ == 9  ff  $_ == 13; }     # 9 10 11 12 13
    for 1..20 { .say if $_ == 9  ff^ $_ == 13; }     # 9 10 11 12
    for 1..20 { .say if $_ == 9 ^ff  $_ == 13; }     #   10 11 12 13
    for 1..20 { .say if $_ == 9 ^ff^ $_ == 13; }     #   10 11 12

In each example we're iterating over the range of numbers from 1 to 20 and output 
those numbers where the flip-flop returns true. Both the right hand side of the 
flip-flop ($_ == 9) and left hand side of the flip-flop ($_ == 13) are evaluated on 
each iteration of the loop. (I've used simple numeric comparison on both sides of the 
flip-flop operators here but, in general, any boolean expression could be used.)

それぞれの例では 1 から 20 までの数値の範囲を iterate over し、flip-flop 演算子が
true を返すものについてその数値を出力します。flip-flop ($_ == 9) の右辺と flip-flop
($_ == 13) の左辺の両方ともがループの繰り返しで毎回評価されます。
(わたしは flip-flop 演算子の両辺ともで単純な数値比較を使うのが通常なのですが、
任意のブール式を使えます)


Each instance of the flip-flop operator maintains it's own little bit of internal 
state to decide when to return True or False. All flip-flop operators are born with 
their internal state set to return False waiting for the moment they can be flipped 
and start returning True.

flip-flop 演算子は、それぞれがいつ True を返しいつ False を返すのかを決定するための
固有の状態を保持しています。すべての flip-flop 演算子はその内部状態を False に
設定して生まれ、その状態を flip して True を返し始める moment を待ち構えています。

In the first and second examples when $_ == 9, the flip-flop operators flips their 
internal state to True and immediately return True.  In the third and fourth examples 
when $_ == 9 the flip-flop operators set their internal state to True but they return 
False on that iteration because of the leading circumflex.

上記の例の一番目と二番目では $_ == 9 となったときに flip-flop 演算子はその
内部状態を True に flip して即座に True を返します。
三番目と四番目の例では $_ == 9 となったときに flip-flop 演算子はその内部状態を
True に flip はしますが、演算子の頭にサーカムフレックスがついているので
繰り返しのその回では False を返します。

Similarly, in the first and third examples above, once the RHS evaluates to True, the 
flip-flop operators flop their internal state back to False on next evaluation and 
return True. In the third and fourth examples, the flip-flops operators flop sooner by 
returning False immediately upon evaluating the RHS True.

同様に、一番目と三番目の例では 右辺が True になったならその flip-flop 演算子は
内部状態を次回の評価時に False に戻し、True を返すようになります。
三番目と四番目の例では、flip-flop 演算子は右辺の評価結果が True になったところで
即座に False を返します。

To make the flip-flop operator flip, but never flop, use a * on the RHS:

flip-flop 演算子を、flip するけれども flop はしないようにするには右辺で * を使います:

    for 1..20 { .say if $_ == 15 ff *; }     # 15 16 17 18 19 20

Perl 6 has another set of flip-flop operators that function similar to the ones 
mentioned above, except the RHS isn't evaluted when the LHS becomes true. This is 
particularly important when both the RHS and the LHS of the flip-flop could evaluate 
to True at the same time. These operators are spelled fff, fff^, ^fff, and ^fff^.

Perl 6 にはもうひと揃いの flip-flop 演算子があります。
これはこれまで説明してきたものと同様の働きをするものですが、
左辺が true になったときに右辺が評価されないという点が異なります。
これはflip-flop の右辺と左辺を評価したときに同時に両者が True となる可能性があるときに特に重要です。
このような演算子群は fff, fff^, ^fff,  ^fff^ のようにつづります。

■_

■_

レジストリアロケータのほかにもちと。

LLVM 3.0登場 - 新レジストリアロケータ実現、さらに高速化 | エンタープライズ | マイナビニュース
LLVM 3.0は2.9から半年の開発期間を経て公開された最新版。主な特徴としては次のようなものがある。

   生成されるコードを大幅に高速化する新しいレジストリアロケータの実装
   C++メモリモデルのフルサポート
   アトミックオペレーションのフルサポート
   MIPSバックエンドの大幅な向上
   grof/gcovスタイルプロファイリングのサポート

Clang 3.0に関しては次の機能追加や改善が実施されている。

   C'1x/C++'11からより多くの機能を実装
   Objective-Cオートマティックリファレンスカウントの実装
   Clang 2.9と比較してより高速なコードの生成
   Clang 2.9と比較してよりコンパイル時間短縮
   Clang 2.9と比較してより良いエラーメッセージ/ワーニングメッセージの提供
LLVM 3.0 Release Notes
LLVM 3.0 includes several major changes and big features:

   llvm-gcc is no longer supported, and not included in the release. We recommend switching
   to Clang or DragonEgg.

   The linear scan register allocator has been replaced with a new "greedy" register
   allocator, enabling live range splitting and many other optimizations that lead to better
   code quality. Please see its blog post or its talk at the Developer Meeting for more
   information.

   LLVM IR now includes full support for atomics memory operations intended to support 
   the C++'11 and C'1x memory models. This includes atomic load and store, compare and 
   exchange, and read/modify/write instructions as well as a full set of memory ordering 
   constraints. Please see the Atomics Guide for more information.

   The LLVM IR exception handling representation has been redesigned and reimplemented, 
   making it more elegant, fixing a huge number of bugs, and enabling inlining and other 
   optimizations. Please see its blog post and the Exception Handling documentation for 
   more information.

   The LLVM IR Type system has been redesigned and reimplemented, making it faster and 
   solving some long-standing problems. Please see its blog post for more information.

   The MIPS backend has made major leaps in this release, going from an experimental 
   target to being virtually production quality and supporting a wide variety of MIPS 
   subtargets. See the MIPS section below for more information.

   The optimizer and code generator now supports gprof and gcov-style coverage and 
   profiling information, and includes a new llvm-cov tool (but also works with gcov). 
   Clang exposes coverage and profiling through GCC-compatible command line options.

たとえば LLVM IR now includes full support for atomics memory operations intended to support the C++'11 and C'1x memory models.C++メモリモデルのフルサポート

アトミックオペレーションのフルサポート ととはちと違うような。

MIPSバックエンドの大幅な向上 バックエンドの「性能」が向上したとかでないと意味が通らないような。 The MIPS backend has made major leaps in this release 「大幅に改善された」とかかなあ。

■_

すすまねえ

2011年12月05日

■_

・「売り切らす」
という言葉を良く使うとあるお店のついったーアカウントがあるんですが、 売り切れ(る)って、下一段活用じゃなかろか。

・PowerShell
xml のデータは簡単に扱えますが、 JSONデータを同様にお手軽に扱えないもんですかねー と今日思った。 Python でごにょごにょしてしまいましたが。

■_ Prolog

しっかり使われているところがある。と。

Natural Language Processing With Prolog in the IBM Watson System | Association for Logic Programming

Natural Language Processing With Prolog in the IBM Watson System

March 31, 2011

Abstract

On February 14-16, 2011, the IBM Watson question answering system won the JeopardyMan 
vs. Machine Challenge by defeating two former grand champions, Ken Jennings and Brad 
Rutter. To compete successfully at Jeopardy!, Watson had to answer complex natural 
language questions over an extremely broad domain of knowledge. Moreover, it had to 
compute an accurate confidence in its answers and to complete its processing in a very 
short amount of time.

IBM の Watson question answering system は、2011年の2月14日から16日に行われた
JeopardyMan vs. Machine という対戦で、Ken Jennings と Brad Rutter
という二人の前 grand champion を倒して勝利しました。
To compete successfully at Jeopardy!,
Watson はても広範囲の領域にわたる知識を超えた複雑な自然言語による質問に答えなければなりませんでした。
加えて、その回答において accurate confidence の演算を行わなければならなかったのですが、
これに非常に短い時間でその処理を完了しなければなりませんでした。

The Question-Answering (QA) problem requires a machine to go beyond just matching 
keywords in documents, which is what a web-search engine does, and correctly interpret 
the question to figure out what is being asked. The QA system also needs to find the 
precise answer without requiring the aid of a human to read through the returned 
documents.

この Question-Ansewering (QA) 問題では、webサーチエンジンが行っているような
ドキュメントにあるキーワードの単なるマッチングを超えたものを機械に要求します。
また、何が問われているのかを理解するために問題を正確に解釈しなければなりません。
このQAシステムは返されたドキュメントを人に読んでもらうような手助け抜きで
正確な回答を見つけ出す必要もあります。

(略)

We required a language in which we could conveniently express pattern matching rules 
over the parse trees and other annotations (such as named entity recognition results), 
and a technology that could execute these rules very efficiently. We found that Prolog 
was the ideal choice for the language due to its simplicity and expressiveness. The 
information in the parse is easily converted into Prolog facts, such as (the numbers 
representing unique identifiers for parse nodes):

  lemma(1, "he").
  partOfSpeech(1,pronoun).
  lemma(2, "publish").
  partOfSpeech(2,verb).
  lemma(3, "Songs of a Sourdough").
  partOfSpeech(3,noun).
  subject(2,1).
  object(2,3).

Such facts were consulted into a Prolog system and several rule sets were executed to 
detect the focus of the question, the lexical answer type and several relations 
between the elements of the parse.
(略)

■_ flip-flop

こんなのになってたのか>Perl 6 の

The Flip-Flop operator « Perl 6 Advent Calendar

The Flip-Flop operator
by perlpilot

Perl 5 has a binary operator called flip-flop that is false until its first argument 
evaluates to true and it stays true (flips) until the second argument evaluates to 
true at which point it becomes false again (flops).  This is such a useful operator 
that Perl 6 also has flip-flop, only it's spelled ff and has a few variants:

Perl 5 にはフリップフロップ (flip-flop) と呼ばれる二項演算子があります。
これは第一引数の評価の結果が true になるまでは false を返し、
そこで flip してそのあとは第二引数の評価の結果が true になるまで true を返します。
そこでこの演算子は flop し、再度 false を返すようになります。
これは便利な演算子なので Perl 6 にも ff やそのいくつかのバリエーションの
名前のついた形で存在しています。

    ff
    ff^
    ^ff
    ^ff^

The circumflex means to skip the end point on that end.
このサーカムフレックス (^) は その end において end point をスキップすることを意味します。

Perhaps some examples are in order …
例を出すのが手っ取り早いでしょう

    for 1..20 { .say if $_ == 9  ff  $_ == 13; }     # 9 10 11 12 13
    for 1..20 { .say if $_ == 9  ff^ $_ == 13; }     # 9 10 11 12
    for 1..20 { .say if $_ == 9 ^ff  $_ == 13; }     #   10 11 12 13
    for 1..20 { .say if $_ == 9 ^ff^ $_ == 13; }     #   10 11 12

(以下略)

.. と ... なんかよりはぱっと見わかりやすいですね (これはバリエーションが二つだけだし)。

■_ ハッシュ

ちょっと前に、Ruby (と Perl) で、「辞書」のデータ構造を 「ハッシュ」と呼称するのはいかがなものかといった趣旨の発言が (twitter 上で)ありましたが、その影響が…!?

2011-12-05 - プログラミング日記

■[C++] ハッシュ

C++でハッシュ(もしくはマップ)として使えそうなのは以下のもの。

    STL: std::hash_map (マップ、C++標準ではないらしい)
    STL: std::map (マップ)
    MFC: CMap (マップ?)
    C++11: std::unordered_map (ハッシュ、VS2010から)


hash_mapよりCMapの方がパフォーマンスが良いらしい。

mapとCMapとunordered_mapは、時間あるときにパフォーマンステストをする予定。

恐らく、ハッシュとしては、unordered_mapを使うことになりそうな予感。

ネットで調べただけなので、詳しい方、間違いのご指摘大歓迎。

「『ハッシュ』として『unorderd_map』を使う」という表現がこうむず痒さを

■_

What Am I Not Learning? : PHP

Hey guys, so I've been learning PHP at school now for a semester, but it seems like 
the only important parts are the superglobals and maybe a few built in functions. 
Everything I've been building has used these elements in some combination. I guess my 
question is, what do I not know? I know there's a next step towards becoming an 
intermediate level PHP programming, but what would that be?

やあ皆さん、わたしは学校で PHP の授業を受け始めたのだけど、
重要なのは superglobals といくつかの組み込み関数だけのような気がしています。
わたしが作ったものはみな、そういった要素をいくつか組み合わせたもので作られています。
わたしが訊きたいのは、自分が知らないことはなんだろうかということなのだろうと思います。
intermediate level の PHP プログラミングに進むための次のステップがあるということは
わかります。でもそれはどういったものでしょうか?


Wait, what exactly have you been learning? Superglobals and built in functions?

このあとにもいくつか返事がついていたけど あんま伸びてなかったw

■_ The Heroes of Java

新しい人のインタビューが

Enterprise Software Development with Java: The Heroes of Java: Eberhard Wolff


The eighth part in my Java interview series: "The Heroes of Java".

Eberhard Wolff
has been working as a developer, consultant and trainer for enterprise solutions based 
on Java technologies ever since Java became available. He has authored three books 
including the first German book on Spring. He regularly contributes to conferences and 
writes articles for several journals. He is a founding member of the Java Champions. 
He works as Architecture and Technology Manager at adesso AG Germany.

(略)


Which programming technique has moved you forwards most and why?
あなたを最も前進させたプログラミング技法はなんですか? また、それはなぜですか?

Unit tests and automated tests. They allowed me to ensure that at least basic functionalities
work without problems and therefore increased my trust in the code I am writing. I find it
odd that more than 10 years after the original paper - which as was called "Test
Infected – Programmers Love Writing Tests" - JUnit is still not used in every project
and if it is, it is often not used correctly i.e. there are no asserts, there is log output
instead for manual instead of automated tests etc.

(略)

Which was the worst programming mistake you did?
これまであなたがやってしまった(プログラミングに関する)最悪のミスは?

I guess it is common to look at code that you have created not too long ago and ask 
yourself how you could possible been so stupid. So I guess my worst mistake is still 
ahead of me - and as far as I know no lives was really hurt by any of the mistakes I 
have made so far, so maybe it is not that bad after all.
Copyright © 2007-2011 by Markus Eisele.. Powered by Blogger.

■_

2011年12月04日

■_

firefox の user.js ではまる。

オライリーカレンダーのために何か買わないと。

■_ Hasekll本

あまり小難しいことを書いてくれるな。ということでいいんでしょうか?

Idea for Haskell books and tutorials : haskell

I'm just now getting into learning haskell and I can already see the power of this language.
I think I may use it in my toolbelt for years to come, might come in handy when I'm next
making a server or something. Above everything I like how concise it is, the syntax is very
simple and you can get a lot done with very little. But as an outsider looking in on the
haskell community, I have a little 2 cents I'd like to give.

Next time you guys make a book or tutorial can you cut the "Haskell is sooooo 
different!" thing? Yeah I come from imperative languages I can see it myself. 
Nearly everything I read about haskell goes in depth on stuff like "you can't 
understand monads so save it for later", and "coming from this or that or 
java, this code might seem strange to you". If the writers spent their time 
explaining and telling you how stuff works instead of talking about how crazy the 
concepts are, half the content would just disappear. The thing is plain old C or Java 
seems just as crazy and weird from a new programmer's perspective as haskell does, but 
when I read their literature it doesn't feel like I'm being preached to.

It looks like haskell literature has something nearly as bad as lisp's but not as bad. 
It's not that the outside is separated from haskell, it's that haskell has separated 
from the outside. If there are any perspective haskell writer's out there, keep the 
crazy abstractions talk and purity in the history section and remember that I just 
want to get to working.

Great language guys, can't wait to learn more and get to coding in it more. Take care!


Haskell: The Math Textbook.

Joking aside, there's an inherent tension between "I just want to get to working"
and "tell me how it works." If I want to explain to you how to write a script
to download a page from a website, you're probably not interested in learning what monads
or what iteratees are. But you can't stop it from showing up, because in the end, you're
going to have to learn it. What we often try to do is move around the material so you're
doing "useful" stuff first, but that necessarily means deferring some material
for later.

■_ バージョン問題

新機能が入って、それを使ったのだけどそれを使えない環境にあわせなきゃならなかった とかなんとか

Goodbye // I'll miss you | jmcnamara [blogs.perl.org]

A blog about the Perl programming language
Goodbye // I'll miss you
By John McNamara on December 3, 2011 2:13 AM

When I started Excel::Writer::XLSX I had, more or less, a clean slate to start with. 
So I chose to use perl 5.10.

わたしが Excel::Writer::XLSX に手をつけた時点では、わたしは先入観なく始める機会を
多かれ少なかれ持っていました。ですから、perl 5.10 を選んだのです。


It was mainly because I wanted to use the defined-or operator //. There were other 
reasons as well but Excel::Writer::XLSX is an API heavy module and, although it may 
sound trivial, defined-or saved me a lot of time.

5.10 を選択した主な理由は、defined-or 演算子 // を使いたかったからです。
そのほかの理由もありましたが、 Excel::Writer::XLSX は API heavy なモジュールで
あったので、defined-or を使えば(些細なものと思えるかもしれませんが)時間が大幅に
節約できたのです。

I also wanted to use some of the other Modern Perl features. In fact I would really 
have liked to have used perl 5.14 but I thought that was probably a step too far.

わたしはまた、そのほかの Modern Perl の機能を使いたいと考えていました。
実際のところわたしは perl 5.14 を使いたかったのですが、それはおそらく
行き過ぎであろうと考えました。

Perl 5.10 isn't exactly new. It came out around the same time that Excel 2007 and the 
xlsx format came out. So, I thought that it was reasonable to use a recent perl for a 
module targeting a recent file format.

perl 5.10 はまったく新しいものというわけではありません。
このバージョンは Excel 2007 や xlsx フォーマットと同じ頃にリリースされています。
ですから、最近のファイルフォーマットをターゲットとしたモジュールには
最近の perl を使うのが合理的であろうと考えたのです。

I was wrong. Clearly organisations upgrade Microsoft Office more frequently then they 
upgrade perl, because most of the emails and forum posts I got were prefixed with 
statements along the lines of "We'd like to use Excel::Writer::XLSX but we're 
stuck on perl 5.8.x".

わたしは間違っていました。
Microsoft Office のアップグレードのスピードは明らかに perl のそれよりも頻繁であったのです。
わたしが受け取ったメールやフォーラムのポストの大半で、
「わたしたちは Excel::Writer::XLSX を使いたいのですが、perl 5.8 でやりたいのです」
という前置きがあったのです。

Most of the people who wrote to me were capable, and generally willing, to upgrade to 
perl 5.10 but for reasons related to their continued employment, couldn't. I've been 
in that situation myself. It isn't fair to ask people to install a 5.10 perl binary 
across tens of Solaris machines even if another part of the company will merrily deploy
Office 2010 across hundreds of machines.

そのようなメッセージを寄せた人々の大半は perl 5.10 へのアップグレードを
妥当なものだと考えていたし、それを望んでいたのですが、
彼らの continued employment のためにできなかったのです。
わたし自身がそのような状況にあります。
たとえ会社のほかの部署で数百台のマシンに対して Office 2010 を merrily deploy
するのだとしても、perl 5.10 のバイナリーを数十台の Solaris マシンにインストール
するようにお願いすることはフェアではありません。


I tried to deal with these requests by maintaining a perl 5.8.2 branch on the GitHub 
repository. That was initially a pain to maintain but the merges got easier. However, 
the branch and the head weren't always in sync and I started to get bug reports for 
the 5.8.2 branch that might or might not exist on the master. Also, some people were 
unaware of the branch and did their own backport. I also started to program looking 
over my shoulder at the maintenance branch and thinking "Do I really need // here. 
If I use || I won't have to port it".

わたしはこのリクエストを、Github リポジトリ上の 5.8.2 ブランチをメンテナンスすることで
対処しようとしました。当初は保守するのが大変であったのですが、マージは簡単に
なって行きました。しかしそのブランチとヘッドは常に同期しているわけではありませんでしたし、
マスターにあるかないかはっきりわからないような、
5.8.2 ブランチに対するバグレポートを受け取り始めました。
また、一部の人たちはそのブランチを考慮せずに自分たちのバックポートを行っていました。
わたしはメンテナンスブランチで自分の肩越しにプログラムを見るようになってしまったので、
#よくわかんね
いったい自分は本当に // を使いたかったのだろうか?
もし || を使っていればこんな移植はせずにすんだのではないだろうか
と思うようになりました。

In the end I just gave up and merged the 5.8.2 branch onto the master and as of version
0.38 the minimum perl requirement for Excel::Writer::XLSX on CPAN is perl 5.8.2.

結局のところわたしは音を上げてしまい、5.8.2 ブランチをマスターにマージしてそれを 0.38 とし、
CPAN 上での Excel::Write::XLSX に対する minimum requirement を 5.8.2 としたのです。

But I swear to God, if I get one single perl 5.6 support request I'll dial the whole 
thing all the way up to perl 5.14.

Goodbye //, I'll miss you : programming

■_ Advent

Perl 6版。 日本人ユーザーでもやってますが。

Day 1: Catching Up With Perl 6 « Perl 6 Advent Calendar

Day 1: Catching Up With Perl 6

by colomon

When we started the Perl 6 Advent Calendar back in 2009, Rakudo was really the only game
in town if you wanted to play with Perl 6. But Perl 6 was intended from the start to be
a language with multiple implementations, and at the moment there are four different Perl
6 implementations of interest. Because there are so many implementations, I'm not going
to give instructions for getting each; instead I'm linking to those instructions.

The most stable and complete implementation is Rakudo Star. This is currently based on 
the last major revision of Rakudo. It's been frozen since July, and so lags a bit 
behind the current Perl 6 spec. It's slow. But it's also pretty reliable.

最も安定していて、完全な実装をしているのが Rakudo Star で、
これは現状 Rakudo の last major revision に基づくものです。
またこれは 7月以来 frozen な状態であるので
最新の Perl 6 のスペックとは多少の差があります。
実行速度は遅いですが、かなり信頼性があります。

The current Rakudo development version is called “Nom”. It's full of great improvements
over the last Rakudo Star release, notably native types, improved performance, and a much
better metamodel. (For example, check out the Grammar::Tracer module, which takes
advantage of the new metamodel to add regex tracing in just 44 lines of code.) It's not
quite ready for prime time yet, as it still misses some features that work in Rakudo Star,
but progress has been incredible, and it's quite possible a new Rakudo Star based on Nom
will be released during this month.

現時点の Rakudo 開発バージョンは "Nom" と呼ばれるものです。
これは最新の Rakudo Star からかなりの改良が行われていて、


Stefan O'Rear's Niecza was just a fledging compiler during last year's Advent calendar, 
but it's a serious contender these days. Built to run on the CLR (.NET and Mono), it 
is relatively zippy, implements a significant portion of Perl 6, and works easily with 
existing CLR libraries.

Lastly, ingy and Mäsak have plans afoot to revive Pugs, the original Perl 6 
implementation in Haskell. So far they've just got it building again on current 
Haskell compilers, but the long-term goal is to get it running on the spec tests again 
and bring it closer to the current spec.

Which implementation should you use? If you're looking for a stable, fairly complete 
Perl 6, Rakudo Star is it. If you just want to explore the language, try Rakudo Nom — 
you will probably run into bugs, but it's significantly more advanced than Rakudo Star, 
and exposing the bugs is a big help to Rakudo's development. If you have an idea which 
would benefit from being able to use CLR libraries, Niecza is fantastic. There's a 
handy comparison chart of the different features available.

Personally, I have all three of these installed on my machine, and have different 
projects underway on each of them.

Finally, please don't hesitate to ask for help, either in the comments here or on the 
#perl6 IRC channel on Freenode. The Perl 6 community is very friendly.

■_

2011年12月03日

■_

Boost#7

・The Art of Computer Programming Vol.1
いやー、ジュンク堂やら紀伊国屋書店でもぜんぜん見なくなりましたねえ> Vol.1 Vol.3 は持っているけど、Vol.2 と Vol.4 をどうするか (Vol.2 の以前の版は持ってたり)。 Vol.4の分冊全部揃えるとなると結構きついのよねえ。 あ、日本語版の話です。 あきらめて英語版のBOXでも買っとくか
The Art of Computer Programming Volume1 Fundamental Algorithms Third Edition 日本語版 (ASCII Addison Wesley Programming Series) The Art of Computer Programming (2) 日本語版 Seminumerical algorithms Ascii Addison Wesley programming series The Art of Computer Programming Volume 3 Sorting and Searching Second Edition 日本語版 (Ascii Addison Wesley programming series) The Art of Computer Programming,Volume 4, Fascicle 0 Introduction to Combinatorial Algorithms and Boolean Functions 日本語版 (ASCII Addison Wesley Programming Se) The Art of Computer Programming Volume 4, Fascicle 1 Bitwise Tricks & Techniques; Binary Decision Diagarms 日本語版 (ASCII Addison Wesley Programming Se) The Art of Computer Programming,Volume 4, Fascicle 2: Generating All Tuples and Permutations[日本語版] (アスキー・アジソンウェスレイシリーズ) The Art of Computer Programming,Volume 4, Fascicle 3: Generating All Combinations and Partitions【日本語版】 (ASCII Addison Wesley Programming Se) The Art of Computer Programming Volume 4, Fascicle 4 Generating All Trees -- History of Combinatorial Generation 日本語版 (ASCII Addison Wesley Programming Series)
Art of Computer Programming, Volumes 1-4A Boxed Set, The (Box Set)
Art of Computer Programming, Volumes 1-4A Boxed Set, The (Box Set)
ここぞとばかりに貼るw

明日から坂の上の雲第三部か。 旅順攻略腺→奉天会戦→日本海海戦と連続になるのかね。

あらすじ | スペシャルドラマ 坂の上の雲
第10回:旅順総攻撃
第11回:二〇三高地
第12回:敵艦見ゆ
最終回:日本海海戦

あら。奉天会戦はスルー? まあしようがないっちゃないか。

■_ fix

"fix' f = f (fix' f)" vs. "fix f = let x = f x in x" : haskellfix - Stanford CS240h 2011 Autumn | Google グループ で。

Alex M

The definition of fix presented in class today was:
今日の授業で教わった fix の定義

  fix :: (a -> a) -> a
  fix f = let x = f x in x

However, an alternative definition of fix (from
http://en.wikipedia.org/wiki/Fixed-point_combinator#Implementing_fixe...)
appears to be:

けれども、Wikipedia にあった別の定義ではこうでした

  fix' :: (a -> a) -> a
  fix' f = f (fix' f)

The two exhibit the same behavior on, say, (const 9):
この二つは同じ動作をします

  Prelude> fix (const 9)
  9
  Prelude> fix' (const 9)
  9
  Prelude>

However, if we have some f like this:
けれども次の f のようなものがあると

  Prelude> let f x = 5 + x

then evaluating the below expression just loops forever without running out of stack:
次の式を評価するとスタックを食いつぶすことなく無限ループします

  Prelude> fix f

whereas evaluating this expression quickly results in stack overflow:
一方こちらを評価した場合には即座にスタックオーバーフローします

  Prelude> fix' f

Also, if we instead do:
同様に、

  Prelude> fix' (\x -> 5 + x)

then we don't run out of stack and just loop forever.
のようにすると、スタックを食いつぶさず、無限ループします。

So I'm quite confused by all this. Also, it's not clear to me how
recursion is "implemented using the fixed-point combinator" in the
"Background: recursive bindings" slide.

ということで、わたしはとても混乱しています。
また、"Background: recursive bindings" slide で
再帰がどのように "implemented using the fixed-point combinator"
(fixed-point コンビネーターを使って実装されているのか)
なのかがよくわかりません。

Any clarification on the above would be appreciated.

Thanks,
Alex
  
David Terei

Good question! The answer pulls in some of the trickiness of the RTS
so its going to be a long but interesting answer. High level is that
fix doesn't actually loop forever, it blocks and fix' does loop
forever with stack allocation so eventually overflows.

To start though, I don't get any difference in behaviour between:

  fix' f
  fix' (\x -> 5 + x)

Both report stack overflow for me (using 7.2.2), in fact if I look at
the code that GHC generates it's exactly the same for both cases.

As for fix vs fix' the STG code for them is as follows (top line
Haskell, bottom line STG):

  fix f = let x = f x in x
  =>
  fix f = let x = f x in x

  fix' f = f (fix' f)
  =>
  fix' f = let x = fix' f in f x

So fix is translated to STG directly as it uses only Haskell
constructs that are also in STG, fix' gets translated a little to
handle laziness (remember from my lecture that 'let' = thunk
creation). Notice fix is a self recursive thunk while fix' is a
recursive function and not tail recursive (so stack allocation).

One thing to be careful of here is that the behaviour in GHCi is a
little different from compiled code.

If you compile the fix' function, it still overflows so same behaviour
in both ghc and ghci.

The cool thing though, is if you compile fix then ghc instead of ghci
when it executes it throws a NonTermination exception!

http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Co...

It seems pretty magical but ghc can actually detect a very small
number of cases of infinite loops and throw an exception instead. As I
covered a little in the lecture, a thunk is not just a suspended
computation but can also be updated. So when a thunk is unevaluated,
pointers to it point to an actual thunk, something that is a piece of
code with an environment that needs to be executed (forced in
functional terminology) to get the actual result. Once the result is
computed, rather than just return it to the original caller that
forced the thunk, the thunk itself is replaced with a pointer to the
computed value. So if any other pointers to the thunk exist (i.e a
shared variable) the work is shared since they now get the value and
not a thunk when they try to force it.

There is an extra detail here. Something called 'blackholes'.
Basically when a thunk is first forced, the thunk is initially
replaced with a kind of sentinel value called a blackhole which simply
indicates that the thunk is currently being forced. If any other
threads come along and try to force the thunk while its in a blackhole
state, they block on the thunk instead of starting a duplicate
computation. (blackholes are also needed for a complication with
garbage collection and thunks).

Now what happens with the fix function when you call it with a non
terminating function like you did is that the thunk that is doing the
know tying here ends up being forced twice. First when you enter fix
and again after the first iteration. At the second iteration it
doesn't re-enter the thunk (which if it did wouldn't cause a stack
overflow but consume the heap and so eventually all memory) but blocks
on the thunk since its in blackhole status.

This paper has a good description of what I just explained:

http://research.microsoft.com/pubs/68449/new-rts.ps.gz

in section '5.1 Space leaks and black holes'.

So in the compiled version of fix this second attempt to force a
blackholed function with the same thread is detected and a
NonTermination exception thrown.

In GHCi though, blackhole detection doesn't work. So the thread blocks
forever. (if you look at your cpu and memory you'll notice nothing is
being consumed since its not looping but blocked). The reason it
doesn't work in GHCi is more a bug than some fundamental limitation.
See bug report:

http://hackage.haskell.org/trac/ghc/ticket/2786

Cheers,
David

  
dm-list-class-11aucs2

At Mon, 28 Nov 2011 21:44:03 -0800,

Alex M wrote:

> So I'm quite confused by all this. Also, it's not clear to me how
> recursion is "implemented using the fixed-point combinator" in the
> "Background: recursive bindings" slide.

> Any clarification on the above would be appreciated.

I have nothing to add to David T's great explanation of why the two
definitions of fix fail differently.  I will say that I find your fix'
function easier to understand, and would have shown that in lecture if
not for the memory issues.  However, if you find:

  fix' f = f (fix' f)

easier to understand, then I think it's fair to imagine that this is
how fix is defined, except that fix has some optimization you don't
care about for understanding how code works.

Now as to how fixed point combinators allow you to implement
recursion, this is also a good question.  First off, what do I even
mean by implementing recursion?  Well, recursion is when you have a
binding or set of bindings, and the set of symbols on the left hand
side can also be used on the right-hand side.  The two examples I gave
are:

        x = (1, snd y)
        y = (fst x, 2)
and
        fibList = 1 : 1 : zipWith (+) fibList (tail fibList)

Now by implement recursion I meant implement something equivalent to
the above two code fragments (i.e., that the above two fragments can
be mechanically translated to), but in which the symbols to the left
of the equals sign do not appear to the right of the equals sign.

How does the fixed-point combinator help?  Well, it lets you have two
names for the same value, so you can use one name to the right of the
equals sign, and another to the left.  In particular, consider this
translation of the definition of x and y:

        (x, y) = fix $ \ ~(x0, y0) -> let x1 = (1, snd y0)
                                          y1 = (fst x0, 2)
                                      in (x1, y1)

Consider just the let statement:  If you replace both x0 and x1 with
x, and replace both y0 and y1 with y, you end up with something
identical to the original recursive definition above.  But now think
about what a fixed-point combinator does--it ensures the input value
of the function is the same as the output value.  So that means that
indeed x0 = x1 and y0 = y1, and thus the above fix call is equivalent
to the recursive code.

Now why does this work?  Well, if you think about the way fix is
implemented, it passes in a thunk that causes an extra copy of the
function to be evaluated.  So in the above code, when the system goes
to evaluate "snd y0", it causes another copy of the function to be
executed.  This second evaluation returns:

    ((1, another-recursive-call), (another-recursive-call, 2))

Forcing either of the thunks marked "another-recursive-call" would
cause yet another copy of the function to be evaluated.  Fortunately,
this isn't necessary, since the code is only asking about the slots
containing 1 and 2, so the recursion terminates.

So far we've considered cases in which the recursion happens exactly
once, or in which it happens infinitely and the program diverges.
However, in the case of functions, recursion often happens some finite
number of times.  Consider the following code:

        fact :: Integer -> Integer
        fact = \n -> if n == 0 then 1 else n * fact (n - 1)

This is a straight-ahead recursive definition of factorial.  (I've
just put the \n to the right of the = for clarity with what follows.)
Now consider this code:

        ffact :: (Integer -> Integer) -> Integer -> Integer
        ffact f = \n -> if n == 0 then 1 else n * f (n - 1)

What is "fix ffact"?  Well, fix ffact should return a particular value
of x such that x = ffact x, right (since fix f = let x = f x in x)?
Well what happens if we expand the definition of ffact x on the right
hand side of that equation?

        x = ffact x
    ==> x = \n -> if n == 0 then 1 else n * x (n - 1)

But wait a second, x now has the exact same (recursive) definition as
fact above, so x is the factorial function.  Another way to look at
this, which I think makes it seem a lot less magical and easier to
understand, is if you imagine using your definition of fix'.  Let's
expand fix' ffact:

        fix' ffact
    ==> \n -> if n == 0 then 1 else n * (fix' ffact) (n - 1)

The key behavior of fix' is that it is self-replicating.  Every time
you force the evaluation of fix' ffact, it spits out another copy the
function ffact, where ffact's argument f is another, identical copy of
"fix' ffact".  So you see that expanding, say, "fix' f 5" will cause
"fix' f" to be expanded 6 times (for n = 5, 4, 3, 2, 1, 0), and when
finally n = 0, there will be no need for further expansion and the
computation can terminate.

  

このあともいくつかやり取りがありますがとりあえずここまで。

■_ S式は

S-expressions: The most powerful data structure available | The (λ) Lambda meme - all things Lisp

S-expressions: The most powerful data structure available in

    data structure
    database
    graphs
    information representation
    lisp
    programming
    s-expressions

Which is the most powerful data structure?
もっとも強力なデータ構造はどれ?

S-expressions are the most powerful data structure currently available, suitable for 
representing arbitrary complex data structures, and that basically means absolutely 
any kind of information.

S式は現在利用できるもっとも強力なデータ構造であり、任意の複雑なデータ構造を表現するのに
向いていて、また、基本的に任意の情報を表現できるものです。
#最後がちといい加減

S-expressions, or S-exps (S stands for symbolic), are best known for their use in the 
Lisp programming language. The most apparent feature of LISP to a non-initiated is the 
use of S-expressions as parenthesized prefix notation (sometimes known as Cambridge 
Polish notation).

S式 (この S は Symbolic の意) はLisp というプログラミング言語で使われていることでよく知られています。
non-niniated にもっとも apparent なLISP の機能はカッコを使った前置記法としてのS式の使用です
(この記法は Cambridge Polish notation と呼ばれることもあります)


Why S-expressions?

The most powerful/general information representation (or data structure or concept) is 
the graph. A graph allows arbitrary information to be associated with one or more 
other arbitrary information (nodes). Considering a graph can also have directed , 
labeled edges, any information (including code, any kind of n-dimensional data, SQL 
database, etc) can be represented using S-expressions.

最も強力かつ一般的な情報の表現(もしくはデータ構造やコンセプト)とはグラフです。
ひとつのグラフはひとつ以上のほかの任意の情報(ノード)と結びついた情報を表現できます。

コードやあらゆる種類の n次元データ、SQLデータベースなどなどのすべての情報を
S式を用いて表現できます。
#Considering から any までの部分の構造がよくわからん
#labeled edges がなければ素直に読めると思うんだけど

Since S-expressions can represent general directed graphs, not just trees, they are 
the most powerful data structure available -- at least until somebody discovers 
something better.

S式は木に限らず一般的な有向グラフを表現できるので、利用な可能なもっとも強力な
データ構造です。少なくとも誰かがもっと良いデータ構造を発見するまでは。


And what about LISP?

That is one of the reasons why LISP is considered to be the most powerful, or 
expressive, language available -- even now, 50 years after its discovery. As a matter 
of fact, LISP is based directly on S-expressions. More than that, in LISP, 
S-expressions are evaluatable units.

それがつまり、その発見から50年たった今現在もなお LISP が最も強力であるとか、表現力を
持った言語であると見なされている理由のひとつです。
実際のところ、LISP は S式における based directly なのです。
さらに言えば、LISP ではS式は評価可能な単位です。

An example of LISP

  (defun fib-trec (n)
    "Tail-recursive Fibonacci number function"
    (labels ((calc-fib (n a b)
                       (if (= n 0)
                         a
                         (calc-fib (- n 1) b (+ a b)))))
      (calc-fib n 0 1)))

"Once you get S-expressions, you get Lisp. All of it. All that remains is to read 
a doc and find out how construct X modifies the sexps you give it. Conceptually, 
S-expression evaluation is all that you need to understand.

Along the way you realise how so much of the power of the language comes from this 
S-expression manipulation, how transparent it is, what all those people meant by 
'writing in the parse tree' (PG) and why they raved about it.

Once you get it, you can never go back. To do so would be wilfully turning away from 
the truth and in doing so you have broken the hacker ethic. You are (and I have) 
allowed to temporarily forget, so long as at the back of your mind you remember that 
'there is a better way', or that you have yet to find the path."

Cambridge Polish notation とかいう名称知らなかった!

S-expression - Wikipedia, the free encyclopedia

In Lisp, the first element of every S-expression is an operator and any remaining 
elements are treated as data. This is called "prefix notation" or 
"Cambridge Polish notation". Due to the close association between 
S-expressions and written representations of data, the term "S-expression" 
in casual conversation often refers to the written representation of an S-expression.

おお、ここでも書いてあった。 polish はまあわかるけど、なぜにケンブリッジ?

■_ げ

メンバーの名前変更されてるじゃねーの!

「ワイルド7」が大迫力の実写映画に。原作ファンなら2度見ようぜ【動画あり】 | 映画・エンタメガイド おすすめ映画

彼らワイルド7のメンバーは、リーダーで殺人犯の飛葉大陸(ひばだいろく、瑛太)、頭脳役で
同じく殺人犯のセカイ(椎名桔平)、ミサイルランチャー付きのサイドカーに乗る爆破魔のパイ
ロウ(丸山隆平)、詐欺師のソックス(阿部力)、元暴力団組長のオヤブン(宇梶剛士)、放火・
殺人犯のヘボピー(平山祐介)とB.B.Q(松本実)だ。

セカイは世界で、バイロウは両国、ソックスが八百で、B.B.Q は……チャーシュー?

■_

■_

これから読む Amazon's Kindle source code: Much ado about nothing — Free Software Foundation — working together for free software How much can the IDE predict what you will write in the next seconds?: How should code search work?

■_ 爪楊枝症候群

Mumbleのチャンネル名正規表現[ \\-=\\w\\#\\[\\]\\{\\}\\(\\)\\@\\|]+ この表現を... - Yahoo!知恵袋

Mumbleのチャンネル名正規表現[ \\-=\\w\\#\\[\\]\\{\\}\\(\\)\\@\\|]+
この表現を読み取れる正規表現に直したいんです
よろしくお願いします。

もしくは[ \\-=\\w\\#\\[\\]\\{\\}\\(\\)\\@\\|]+
が何を表しているのかが分かる方はいないでしょうか? 

バックスラッシュが二重になっているのは文字列として記述しているから。として、 なんだって文字クラスでこんなにエスケープするかねえ。

■_ 今日の収穫物

2011年12月02日

■_

今日の意味不明
「明言化」たぶん「明文化」と「明言」が混ざった。 偉そうなことを書いていてもこういうのがあると(ry

3.6 で止めてた Firefox を一気に 8.0 に上げた。

■_

■_

C#, C♯, C#相談室 Part68 

912 デフォルトの名無しさん [sage] 2011/12/01(木) 23:27:15.56 ID: Be:
    研修1ヶ月、実務に入って3ヵ月になる新人です。
    入門書的なテキストじゃ少し物足りないってレベルなのですが
    オススメの参考書とかあったら教えてください。 

913 デフォルトの名無しさん [sage] 2011/12/01(木) 23:46:08.93 ID: Be:
    >>912
    プログラミング.NET Framework第3版 

914 デフォルトの名無しさん [sage] 2011/12/02(金) 09:05:27.85 ID: Be:
    >>913
    これは良書、買い 

916 デフォルトの名無しさん [sage] 2011/12/02(金) 09:18:55.44 ID: Be:
    『.NETのクラスライブラリ設計 』の糞訳の人じゃん。 

917 デフォルトの名無しさん [sage] 2011/12/02(金) 09:40:23.17 ID: Be:
    >>912
    「VisualC#実践講座」 

918 デフォルトの名無しさん [sage] 2011/12/02(金) 10:19:42.69 ID: Be:
    C言語のK&Rだって糞訳だけど、買わなきゃいけない本なんだよ! 

919 デフォルトの名無しさん [sage] 2011/12/02(金) 10:53:32.57 ID: Be:
    本当の糞訳ってのはプログラミング言語C++第三版だろ。 

920 デフォルトの名無しさん [sage] 2011/12/02(金) 11:01:03.56 ID: Be:
    ここで誰も「原本を買え」っていう奴がいなくて安心した 

921 デフォルトの名無しさん [sage] 2011/12/02(金) 11:26:02.73 ID: Be:
    原本?? 

922 デフォルトの名無しさん [] 2011/12/02(金) 11:27:02.50 ID: Be:
    機械翻訳とコピペだけで内容を確認せず仕上げる糞訳者は晒さないとな。 

923 デフォルトの名無しさん [sage] 2011/12/02(金) 11:52:37.08 ID: Be:
    いつもコピーしている奴は原本なんて言っちゃうんだろうなw 

924 デフォルトの名無しさん [sage] 2011/12/02(金) 12:16:35.37 ID: Be:
    >>923 >>921
    自炊はしてみたいとは思うがやってない…

    翻訳する元の本を原本っていわないか?
    たとえば>>918だったらhttp://amzn.com/0131103628 とか 

925 デフォルトの名無しさん [sage] 2011/12/02(金) 12:48:14.20 ID: Be:
    >>919
    それ買ってあまりの糞訳に絶望して本屋に返品しに行ったわ
    すっげええ嫌な顔されたけどあれはもはや日本語じゃなかった 

926 デフォルトの名無しさん [sage] 2011/12/02(金) 12:52:04.03 ID: Be:
    原著だろ。 

927 デフォルトの名無しさん [sage] 2011/12/02(金) 13:26:35.88 ID: Be:
    翻訳前の本を原本というみたいだけど
    普通は複写に対してオリジナルを原本,翻訳される本を原著というのが一般的かと思う。 

928 デフォルトの名無しさん [sage] 2011/12/02(金) 14:24:25.15 ID: Be:
    Richter本はなんで訳者を駄目な人に変えちゃったんだろうな...

    MS Pressは良書ほど糞訳が付きやすいような気がする
    豊田孝とか読んでてイライラしますねん 

929 デフォルトの名無しさん [sage] 2011/12/02(金) 21:23:34.00 ID: Be:
    >>928
    前の人はもう.NETとは関わってないみたいだからしょうがないのかもねえ 

原本は翻訳本の元の本を指すのには使わないんじゃないかなあ。 ところで 928 で名前の出ている人が書いた PowerShell の本が…… おや、こんな夜中に誰かきたようだ。

■_ 140字限定

Wolfram Blog : The 2011 Mathematica One-Liner Competition

The 2011 Mathematica One-Liner Competition

The Mathematica One-Liner Competition at last year's Wolfram Technology Conference was
such a popular success that we did it again this year. As readers of this blog may recall,
last year's winning entry, submitted by Stephan Leibbrandt, was a complete, animated
simulation of particles coalescing under gravitational and repulsive forces. This year's
winner takes advantage of the integration of Mathematica and 
Wolfram|Alpha that debuted in Version 8.

スクリプト(プログラム)を見てもなにがなにやらわからんな。 もうちょっと気楽に買えればなあ>ませまちか

それにつけても以下略

■_ Learn Code The Hard Way

Zed が今度は正規表現の入門本に着手してるらしい。

Learn Code The Hard Way -- Books And Courses To Learn To Code

Introducing Learn Regex The Hard Way

If you run into strings like "\s+.?(?i)a+b?" and your eyes glaze over like a
pair of old fashioned donuts, then this book is for you. When you're done you will be
able to read that string, understand what's going on with regex, learn when to use them,
learn to write them, and learn how to write simple parsers to avoid abusing regex to
process your strings. 

Download The ALPHA Release

Right now there's an HTML version of the book up for people to read.
Helping Edit

If you are an experienced programmer and want to edit code that's in the book, or help
with editing, then hit the git repo and start digging. You know what to do:

    Fork my git repo.
    Make your changes.
    Send me a merge request.

By asking me to merge your changes in you agree that I retain copyright. Please don't
make me make you sign something to prove that.

Git か。

見出しを抜き出すとこんな感じ。

Learn Regex The Hard Way Scanning And Parsing Text Without Going Insane

Preface
Introduction: Giants In Tiny Pants
 0.1 Regular Expressions Are Character Algebra
 0.2 How To Learn A Symbolic Language
 0.3 The Giants In Tiny Pants Problem
 0.4 Slaying Giants In Tiny Pants With Parsing
 0.5 How To Use This Book

I  Basic Skills
1 Exercise 0: The Setup
2 Exercise 1: Your First Regex
3 Exercise 2: Finding Specific Strings
4 Exercise 3: Matching Any Character
5 Exercise 4: Matching Sets Of Characters
6 Exercise 5: Inverting Sets Of Characters
7 Exercise 6: Translating Simple Regex
8 Exercise 7: The Beginning And End
9 Exercise 8: Optional Elements
10 Exercise 9: Repetition, Repetition
11 Exercise 10: Frugality In All Things
12 Exercise 11: This Or That
13 Exercise 12: Translating Complex Regex
14 Exercise 13: Escaping Things
15 Exercise 14: Escape Sequences You May Need
16 Exercise 15: Grouping And Captures
17 Exercise 16: Search And Replace
18 Exercise 17: The Limits Of Regular Expressions
19 Exercise 18: Useful Extensions
20 Exercise 19: Verbose Regex With Comments
21 Exercise 20: Named Captures
22 Exercise 21: Extensions To Avoid
23 Exercise 22: Translating Insane Regex
24 Exercise 23: Memorize Your Symbology
25 Exercise 24: Debugging Regex
26 Exercise 25: Mid-term Exam
27 Exercise 26: When Not To Use Regex

II  Advanced Topics
28 Exercise 27: Using sed To Alter Files
29 Exercise 28: Writing Edit Scripts for sed
30 Exercise 29: Using sed Syntax In Vim
31 Exercise 30: Hot Vim Tricks With Regex
32 Exercise 31: Using grep To Find Stuff
33 Exercise 32: Grepping For Specific Things
34 Exercise 33: Code Searching With ack
35 Exercise 34: Simple Reporting Wtih awk
36 Exercise 35: Using Regex In Python
37 Exercise 36: Using Regex In Ruby
38 Exercise 37: Using Regex In JavaScript
39 Exercise 38: Using Regex In C
40 Exercise 39: The Concept Of Lexing
41 Exercise 40: Designing A Lexicon
42 Exercise 41: Writing The Lexer In Python
43 Exercise 42: Testing The Python Lexer
44 Exercise 43: Writing The Lexer In Ruby
45 Exercise 44: Testing The Ruby Lexer
46 Exercise 45: How A Simple Parser Works
47 Exercise 46: Designing The Grammar
48 Exercise 47: Writing The Parser In Python
49 Exercise 48: Testing The Python Parser
50 Exercise 49: Writing The Parser In Ruby
51 Exercise 50: Testing The Ruby Parser
52 Exercise 51: Extending The Parser
53 Exercise 52: Final Exam
54 Next Steps

■_ Coding - the new Latin

なんか BBC の記事にこんなのが

BBC News - Coding - the new Latin

Coding - the new Latin
Comments (618)

The campaign to boost the teaching of computer skills - particularly coding - in 
schools is gathering force.

Today the likes of Google, Microsoft and other leading technology names will lend their
support to the case made to the government earlier this year in a report called Next Gen.
It argued that the UK could be a global hub for the video games and special effects
industries - but only if its education system got its act together.

The statistics on the numbers going to university to study computing make sobering reading.
In 2003 around 16,500 students applied to UCAS for places on computer science courses.

(略)

コメント多すぎで追いかけきれねー ○| ̄|_

■_

ネタはあれども時間が

2011年12月01日

■_

師走。

昨日のお勧め本を挙げる話、ワインバーグの本の好きなのをどれでも。 と言うのでも良かったかも。

■_

Monthly programming language trends | Jobs Tractor ←にあるデータ

Language	Jobs
PHP	744
Java	714
Objective C	426
SQL	334
Ruby	244
Android	220
JavaScript	215
C#	183
Flash	170
C++	134
Python	114
C	76

を使って

> x<-read.delim("clipboard")
> x
      Language Jobs
1          PHP  744
2         Java  714
3  Objective-C  426
4          SQL  334
5         Ruby  244
6      Android  220
7   JavaScript  215
8           C#  183
9        Flash  170
10         C++  134
11      Python  114
12           C   76
> x[,1]
 [1] PHP         Java        Objective-C SQL         Ruby        Android    
 [7] JavaScript  C#          Flash       C++         Python      C          
12 Levels: Android C C# C++ Flash Java JavaScript Objective-C PHP ... SQL
> pie(x[,2], label=x[,1],clockwise=TRUE)

結果。

x を転置すればもう少しすっきりできるのかな。

■_

何故ハイパーカードは死ななければならなかったのか - karasuyamatenguの日記 yebo blog: なぜ、HyperCardは死ななければならなかったのか Loper OS » Why Hypercard Had to Die

■_

■_

デザインパターンのデコレーターパターンと Python のデコレーターの違いは? という話から

Whats the difference between Python decorators and Decorator Pattern? - Stack Overflow

Decorators in python are the application of decorators in decorator design. They are both
the same thing one is talking about the language implementation and the other of a design
and computer science concept.

■_ 恥の壁?

"Python 3 Wall of Shame" http://python3wos.appspot.com/?_

■_

Any Technology: Dodgy Coder: 'Egyptian brackets', "Yoda Conditions", "Pokemon Exception Handling" and other programming classics にあるバグの種類。 見覚えがあるのが大半ですが

Different kinds of bugs

Heisenbug
Higgs-Bugson
Hindenbug
Counterbug
Bloombug
Schrodinbug
Loch Ness Monster Bug
UFO bug
Mandelbug
Brown-paper-bag bug
Sorcerer's apprentice mode
Mad girlfriend bug

なんだ UFO バグとかLoch Ness Monster バグってw 出典を見ると Jargonファイルとかあるんだけどあったかなあ。

■_ あとでよむ

数日前のアレに対する反論(たぶん)。

Your Community is NOT Your Tools. @ iBanjo

Your Community is NOT Your Tools.

This entry was posted by Ben Collins-Sussman on Wednesday, 30 November, 2011 at

(Disclaimer: I'm one of the ‘old guard' open source guys. I co-founded the Subversion 
project back in 2000 and am a proud member of the ASF. These opinions are my own.)

お断り:
わたしは 'old guard' open source guys の一人です。
2000 年に Subversion プロジェクトを co-found したし、
ASF の一員であることに誇りを持っています

A very popular blog post has been going around lately called Apache Considered Harmful, 
which criticizes the Apache Software Foundation (ASF) for being impossible to work 
with. On the surface, it looks a bit like a culture war between older and younger 
generations of open source hackers: the older generation is portrayed as stodgy and 
skeptical of distributed version control systems, making the ASF inhospitable to a 
younger generation used to the fast-and-freewheeling world of git and Github.


One of the ASF's leaders, Jim Jagielski, then wrote a blog response which seems to say, 
“We're not irrelevant; we just have high integrity. We care about long-term health of 
open source projects, not passing fads or hip popularity contests.”

一つ前へ 2011年11月(下旬)
一つ後へ 2011年12月(中旬)

ホームへ


リンクはご自由にどうぞ

メールの宛先はこちらkbk AT kt DOT rim DOT or DOT jp