ときどきの雑記帖 i戦士篇

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

一つ前へ 2009年2月(中旬)
一つ後へ 2009年3月(上旬)

ホームへ

2009年02月28日

■_

shibuya.lisp Technical Talk #2 shibuya.lisp TT#2 無事開催! - わだばLisperになる - cadrグループ いってきました。 感想等はあとで …iPod Touchほしくなった(笑) あと、ustreamに乗らなかった黒田さんのセッションが一番面白かった気が。 いや確かに甲乙つけがたくはあるのですが、自分の好みとして。 あれは金払ってでもみたい(聴きたい)代物。

・今月の皇帝陛下
海戦では陛下の出番はないわな(^^; そしてネルソンこえー。

・ダムエー
ギレンとキシリアの駆け引きと、おいてきぼりなドズル。 そしてシャア。ア・バオア・クーを無視して本国にっておまい。

・本日のなつたん駆動読書
進捗なし○| ̄|_

■_

めもがき:2009年2月27日分
○[NetBSD] テキストファイルの文字コード vs localeの文字コード

DragonFlyBSDにCitrusの移植をしてたjoerg氏からお手紙モラタ、要約すると

    * テキストファイルの文字コードとlocaleのcodesetが違う場合
      プログラム書くのが死ぬほど苦痛だぜヒャッハー。
    * だからGNU libiconvのようにiconv(3)でwchar_tに変換できるようにした方がいいんじゃねーか。
    * もしくは文字コード指定可能なmbrtowc(3)を実装するべきなんじゃねーの?

というご意見をたまわわわわった。

(略)

文字コード指定可能なmbrtowc(仮にmbrtowc_encとする)を追加するってアイデアの方は
実はこれ、おいらが只今絶賛サボり中の TALE(=Thread Aware Locale Extension)実装の中にある
mbrtowc_l(3)ととっても良く似たもの。

…なんだけども、こっちはあくまでlocale_tで扱える文字コードしか指定できないので
UTF-16/32なんかのL'\0' != '\0'になる文字コードは扱えない、するとやっぱし
別インタフェースを用意する羽目になるのよな。

でもそれって

    mbtowc
    mbrtowc
    mbtowc_l
    mbrtowc_l
    mbtowc_enc
    mbrtowc_enc

ちゅう具合で「似てるけどちょっとだけ違う関数が大量に増える」という
最低最悪の五つ子オソマツ君なソリューションなので、おいらとしては絶対にacceptできまへん。
strcpyとstrncpyとstrlcpyとstrcpy_sの悲劇を繰り返すのはやめようぜ。

そもそもmbrtowc_l自体、TOGの Distributed I18N Frameworkのように
mbstate_tにAttrObject(≒locale_t)を埋め込むというアプローチをとってさえいれば
新たに関数追加せずとも既存のmbrtowc(3)で問題なかったんだよな。
ほんとにglibc2方面はこういう設計ヘタクソすぐる、ぐんにょり。

まぁでもMacOS XとかMSVC++はすでにTALEを(微妙な差異があるものの)実装しちゃってるので
後発組としては長いものに巻かれるしかなさげ。

メールの返事書くのめんどい… 

最後の一行が本音ですか?w

名前は…なんかいい解決法はあるんでしょうか。

■_ The History of Python: First-class Everything

ちょっと手を入れなければならないところが残ってるけど(それは毎度のこと)

The History of Python: First-class Everything (全てがファーストクラス)
First-class Everything

[Folks, please don't use the comments section of this blog to ask questions. If you 
want to suggest a topic for a future blog entry, send me email. (Use Google to find my 
home page, which has my email address.) If you want to propose a change or discuss the 
merits of alternative designs, use the python-ideas mailing list at python.org.]

良いこのみんなにお願い:
このblogのコメント欄に質問を書くことは止めてもらえないだろうか。
もしこれからのエントリでなにか suggest したいことがあるのなら、emailで
送ってもらいたい。ぐぐってわたしのホームページを見つけて、そこにあるアドレスに
お願いする。Pythonに対する変更の提案だとか
merits of alternative designs についての議論といったことをしたいのなら
python-ideas at python.org を使って欲しい。

One of my goals for Python was to make it so that all objects were "first 
class." By this, I meant that I wanted all objects that could be named in the 
language (e.g., integers, strings, functions, classes, modules, methods, etc.) to have 
equal status. That is, they can be assigned to variables, placed in lists, stored in 
dictionaries, passed as arguments, and so forth.

Python でのわたしの目標のひとつは全てのオブジェクトを
"first class." (ファーストクラスオブジェクト、第一級市民)
とすることでした。これにより、言語において名をつけることのできる全てのオブジェクト
(整数や文字列、関数、クラス、モジュール、メソッドなどなど)を等しいステータスを
持たせたかったのです。つまり、それらのオブジェクトは変数に代入することができるし、
リストの中に置くことができたり、ディクショナリに格納したり、引数として渡すことが
できたりといったことが可能であるということです。

The internal implementation of Python made this simple to do. All of Python's objects 
were based on a common C data structure that was used everywhere in the interpreter. 
Variables, lists, functions, and everything else just used variations of this one data 
structure---it just didn't matter if the structure happened to represent a simple 
object such as an integer or something more complicated such as a class.

Python の内部的な実装は上記のことを単純にします。Pythonのすべてのオブジェクトは
Pythonインタープリター内部のいたるところで使われている
一般的な Cのデータ構造に基づいたものであり、それは
変数であり、リストであり関数であり、そして
everything else just used variations of this one data structure
そういった構造体が整数のような単純なオブジェクトを表現しているのか
あるいはもっと複雑なクラスのようななにかを表現しているのかは重要ではありません。

Although the idea of having "first-class everything" is conceptually simple, 
there was still one subtle aspect of classes that I still needed to address---namely, 
the problem of making methods first class objects.

ファーストクラスオブジェクトを持つという考え方はコンセプトとしては単純なのですが
わたしが対処しなければならない
メソッドをファーストクラスオブジェクトにするという問題が
残っていたのです。
#あとでなおす

Consider this simple Python class (copied from last week's blog post):
次のような単純なPython のクラスを考えてみましょう

class A:
     def __init__(self,x):
         self.x = x
     def spam(self,y):
        print self.x, y

If methods are going to be first-class objects, then they can be assigned to other 
variables and used just like other objects in Python. For example, someone could write 
a Python statement such as "s = A.spam". In this case, the variable 
"s" refers to a method of a class, which is really just a function. However, 
a method is not quite the same as ordinary function. Specifically, the first argument 
of a method is supposed to be an instance of the class in which a method was defined.

メソッドをファーストクラスオブジェクトであったならば、
メソッドは他の変数に代入することや、
Python の他のオブジェクトのように使うことが可能です。
たとえば誰かが  "s = A.spam" のような Python 文を書くことができます。
この場合、"s" という変数は実際には単なる関数であるクラスのメソッドを参照しています。
しかしながらメソッドは通常の関数と全く同じなものではありません。
特に、メソッドの第一引数はそのメソッドを定義しているクラスのインスタンスであることが
期待されています。


To deal with this, I created a type of callable object known as an "unbound 
method." An unbound method was really just a thin wrapper around the function 
object that implemented a method, but it enforced a restriction that the first 
argument had to be an instance of the class in which the method was defined. Thus, if 
someone wanted to call an unbound method "s" as a function, they would have 
to pass an instance of class "A" as the first argument. For example, 
"a = A(); s(a)". (*)

これを扱うために、わたしは "unbound method." として知られている
呼び出し可能オブジェクト (callable object)の型を作りました。
unbound method は実際には
メソッドを実装している関数オブジェクトを包む単なる薄いラッパーです。
しかし第一引数がメソッドを定義したクラスのインスタンスでなければならないという
制限がされています。
したがって、誰かが関数として unbound method "s" を呼び出したいと
考えた場合、その人は "s" の第一引数にクラスのインスタンスを
渡さなければならなくなるでしょう。
"a = A(); s(a)". (*)
といった感じに。

A related problem occurs if someone writes a Python statement that refers to a method 
on a specific instance of an object. For example, someone might create an instance 
using "a = A()" and then later write a statement such as "s = 
a.spam". Here, the variable "s" again refers to a method of a class, 
but the reference to that method was obtained through an instance "a" . To 
handle this situation, a different callable object known as a "bound method." 
is used. This object is also a thin wrapper around the function object for the method. 
However, this wrapper implicitly stores the original instance that was used to obtain 
the method. Thus, a later statement such as "s()" will call the method with 
the instance "a" implicitly set as the first argument.

これに関連した問題が
あるオブジェクトの特定のインスタンスのメソッドを参照するような
Pytthon 文を誰かが書いたときに発生します。
たとえば、
 "a = A()" を使ったインスタンスを作り
その後  "s = a.spam".という文を誰かが書くようなことがあるかもしれません。
ここで変数 "s"  は再びあるクラスのメソッドを参照しますが、
その参照しているメソッドはインスタンス  "a" を通じて得られたものなのです。
To handle this situation, a different callable object known as a "bound method." 
このシチュエーションに対処するため "bound method." として知られる
異なるcallable object を使用します。
この callable object もメソッドである関数オブジェクトを包む薄いラッパーです。
However, this wrapper implicitly stores the original instance that was used to obtain 
the method. Thus, a later statement such as "s()" will call the method with 
the instance "a" implicitly set as the first argument.
しかし、このラッパーは暗黙裡にそのメソッドを得るために使われた
元のインスタンスを格納しているのです。
このため、あとの文で "s()" としたときに
その第一引数には暗黙のうちに "a" のインスタンスを伴っって
呼び出されるようになります。

In reality, the same internal object type is used to represent bound and unbound 
methods. One of the attributes of this object contains a reference to an instance. If 
set to None, the method is unbound. Otherwise, the method is bound.

現実には
同じ内部オブジェクト型がbound method にも unbound method にも使われています。
このオブジェクトのアトリビュートのひとつがあるインスタンスを参照しています。
None をセットすると、そのメソッドは unbound になります。
それ以外の場合はメソッドは bound されています。

Although bound and unbound methods might seem like an unimportant detail, they a 
critical part of how classes work underneath the covers. Whenever a statement such as 
"a.spam()" appears in a program, the execution of that statement actually 
occurs in two steps. First, a lookup of "a.spam" occurs. This returns a 
bound method--a callable object. Next, a function call operation "()" is 
applied to that object to invoke the method with user supplied arguments.

メソッドが bound であるか unbound であるかは重要でない些細なことのように
感じられるかもしれませんが、
they a critical part of how classes work underneath the covers. 
それらはクラスがどのように動作するかに関する critical part なのです。
プログラムの中で  "a.spam()" のような文が現れたときはいつでも
実際には二段階のステップを踏んで文の実行がされます。
まずはじめに"a.spam" のルックアップが発生します。
これは callable objecet である bound method を返します。
Next, a function call operation "()" is 
次に関数呼び出し "()" が
ユーザーが引数を提供したメソッドを起動したオブジェクトに適用されます。

__________
(*) In Python 3000, the concept of unbound methods has been removed, and the 
expression "A.spam" returns a plain function object. It turned out that the 
restriction that the first argument had to be an instance of A was rarely helpful in 
diagnosing problems, and frequently an obstacle to advanced usages --- some have 
called it "duck typing self" which seems an appropriate name. 

Python 3000では、unbound method というコンセプトは削除されました。
そして "A.spam" という式は素の関数オブジェクト (plain function object)
を返します。第一引数がAのインスタンスでなければならないという制限は
rarely helpful in diagnosing problems, 
そしてしばしば advabced usage の障害となります。
--- some have called it "duck typing self" which seems an appropriate name. 
一部の人はそれを "duck typing self" と呼びます。

■_


Win32API質問箱 Build77 
21 デフォルトの名無しさん [sage] Date:2009/02/26(木) 21:08:04  ID: Be:
    DDBとDIBって同じじゃないの? 

22 デフォルトの名無しさん [sage] Date:2009/02/26(木) 21:18:21  ID: Be:
    >>21
    同じでないから別の言葉になっている。
    大雑把に言えば、DDBは内部形式。
    DIBは.bmpそのまま。 

23 デフォルトの名無しさん [sage] Date:2009/02/26(木) 21:36:24  ID: Be:
    >>22
    大雑把に言い過ぎて間違ってる 

24 デフォルトの名無しさん [sage] Date:2009/02/26(木) 21:37:11  ID: Be:
    32bppなら気にすることもないだろ 

27 デフォルトの名無しさん [sage] Date:2009/02/26(木) 21:56:10  ID: Be:
    D:デバイス
    D:いぞん
    B:ビットマップ

    D:デバイス
    I:どくりつ
    B:ビットマップ

    覚えやすいね 

28 デフォルトの名無しさん [sage] Date:2009/02/26(木) 21:57:40  ID: Be:
    見事そこだけカタカナのままではないのが素晴らしい。 

31 デフォルトの名無しさん [sage] Date:2009/02/26(木) 22:39:33  ID: Be:
    D:デバイス
    D:どくりつ
    B:ビットマップ

    D:デバイス
    I:いぞん
    B:ビットマップ

    覚えやすいね 

32 デフォルトの名無しさん [sage] Date:2009/02/26(木) 23:03:39  ID: Be:
    もうダメだこのスレ 

Ruby 初心者スレッド Part 25 
988 デフォルトの名無しさん [sage] Date:2009/02/28(土) 03:20:38  ID: Be:
    emacsにruby-modeを入れて使ってみたのですが、
    自動でインデントしてくれません。
    C-M-\ とコマンドするとインデントちゃんとしてくれるのですが。

    自動インデントの機能は無いのでしょうか?
    ruby-1.8.7のソースにくっついてきたelispパッケージを入れてます。 

989 デフォルトの名無しさん [sage] Date:2009/02/28(土) 06:45:44  ID: Be:
    Emacsの行改にEnterキーを使ってるおとこのひとって… 

990 デフォルトの名無しさん [sage] Date:2009/02/28(土) 07:00:17  ID: Be:
    てか Ruby あんま関係ないな

    一般論としては、どの mode でも C-j あたりでスマートインデントつき改行が実行される
    Enter キーにスマートインデントを設定すると意外とウザいことが知られてるので普通は敢えて設定はされてない
    Enter キー押したあとに Tab キー(>>989的にはたぶん C-i)を押せば用は足りるからな
    それでも Enter キーで自動インデントして欲しいという人は emacs.el (旧称 .emacs) に書け

    (add-hook 'ruby-mode-hook
    '(lambda ()
    (inf-ruby-keys)
    (define-key ruby-mode-map "\C-m" 'ruby-reindent-then-newline-and-indent)
    (define-key ruby-mode-map "\C-j" 'newline)))


    inf-ruby-keys でエラーが出る環境の人は行ごと消してよし 

それはしらなかった。>エンターキーのバインディング



初心者のためのプログラミング言語ガイド Part14 [

4 デフォルトの名無しさん [sage] Date:2009/02/27(金) 09:41:26  ID: Be:
    (1)初心者がいきなりCは難しいからやめたほうがいい
    (2)Schemeは難しいし、勉強しても何も作れないのでやめたほうがいい
    (3)ハスケルは難しいし、勉強しても何も作れないのでやめたほうがいい

    ↑これらの、(1)、(2)、(3)を勧めてくるのは
    初心者を挫折させるためのトラップなので
    まともに話を聞いてはいけない。

    なんで初心者をわざわざ挫折させないといけないかというと
    プログラミングなんて誰でもできるので親切に教えると
    ゆくゆくは自分のライバルになると恐れているのである。 

5 デフォルトの名無しさん [sage] Date:2009/02/27(金) 09:53:40  ID: Be:
    くだらん。 

6 デフォルトの名無しさん [sage] Date:2009/02/27(金) 13:10:23  ID: Be:
    (4)として前スレの数学議論も入れた方がいいな
    NGワード: 数学 scheme haskell 

7 デフォルトの名無しさん [sage] Date:2009/02/27(金) 13:14:25  ID: Be:
    言語で言えばCとSchemeはむしろ必修科目だろ。 

8 デフォルトの名無しさん [sage] Date:2009/02/27(金) 13:17:27  ID: Be:
    確かに微積線形すら理解してない奴がプログラマとか笑っちゃうけど
    初心者言語ガイドで数学やれってのはスレ違いだよな。 

9 デフォルトの名無しさん [sage] Date:2009/02/27(金) 13:19:47  ID: Be:
    凝ったことやらないならどちらもシンプルだし資料も沢山あるので
    最初の一歩としては楽な部類に入る言語 

10 デフォルトの名無しさん [sage] Date:2009/02/27(金) 13:22:11  ID: Be:
    まあ数学議論はこっちいけってことで
    http://pc11.2ch.net/test/read.cgi/tech/1171457185/ 

11 デフォルトの名無しさん [sage] Date:2009/02/27(金) 13:29:01  ID: Be:
    MLで十分
    Schemeなんて必要ない 

12 デフォルトの名無しさん [sage] Date:2009/02/27(金) 23:44:34  ID: Be:
    Cが難しいからやめとけって・・・
    じゃあ何から始めるのがいいの? 

13 デフォルトの名無しさん [sage] Date:2009/02/27(金) 23:47:15  ID: Be:
    俺はBASICから始めましたが何か 

14 デフォルトの名無しさん [sage] Date:2009/02/27(金) 23:53:53  ID: Be:
    40代のおっさんですか? 

15 デフォルトの名無しさん [sage] Date:2009/02/28(土) 00:19:30  ID: Be:
    なんか、前スレで業務知識が云々って言ってたけど
    業務で数学使うなら数学も業務知識だろ
    経済シミュレーションソフトとか開発するのなら経済学がいるかもしれんし 

16 デフォルトの名無しさん [sage] Date:2009/02/28(土) 00:49:54  ID: Be:
    ちょっとおもしろいデータ

    2008年第4四半期の米国市場でのプログラミング言語関連書籍の販売部数のシェア。
    緑色は増加傾向、赤は減少傾向を示していて、色が濃いほど増減が激しいことを表している 出典:O'Reilly Media
    http://www.atmarkit.co.jp/news/200902/27/l_langs01.jpg
    http://www.atmarkit.co.jp/news/200902/27/langs.html 

17 デフォルトの名無しさん [sage] Date:2009/02/28(土) 00:51:31  ID: Be:
    ホビープログラミングにはiPhoneなんてのもありなのかもしれないな。
    日本じゃ開発コミュニティが閑散としてるけど… 

18 デフォルトの名無しさん [sage] Date:2009/02/28(土) 01:03:48  ID: Be:
    Objective-Cの伸びに噴いた。965%てww 

19 デフォルトの名無しさん [sage] Date:2009/02/28(土) 01:23:33  ID: Be:
    業務知識ってのが具体的に何を指してるのか不明だけど
    アドホックな知識は30歳過ぎてからでもいくらでも身につく。
    対して,汎用的で抽象的な知識は若いうちに
    身につけておかないと使いこなせない。

    高いレベルに目標を置くのならば,ただ闇雲に勉強するのではなく
    「今は何を身につけるべき時なのか」を常に意識して取り組むことが重要だ。 

20 デフォルトの名無しさん [sage] Date:2009/02/28(土) 01:26:43  ID: Be:
    うぜぇよ 

21 デフォルトの名無しさん [sage] Date:2009/02/28(土) 01:52:16  ID: Be:
    C#すげーな
    Java失速し過ぎ 

23 デフォルトの名無しさん [sage] Date:2009/02/28(土) 02:03:13  ID: Be:
    Javaの中級レベルはJavaDocとWebあれば足りるから
    そこら辺が減少したとみるべき数字だな。


    C#の伸び止まりはVB、VC++からの移行が安定したって事なのかな。
    そう考えると、未だにVB6やVB.netで迷走している日本は
    IT後進国なんだろうな、、、、、、 

26 デフォルトの名無しさん [sage] Date:2009/02/28(土) 05:01:56  ID: Be:
    Cは覚える事少ないから初心者には良い言語だと思う。
    書籍も多いし、ライブラリも多いし、他の言語にステップアップし易いし、
    コンパイラは無料だし、実行速度は速いし、サンプルコードも沢山ある。

    Cに限らず、興味を持った言語から取り組めば良いと思うけどね。
    自分の場合は最初はSmallalkだったなぁ… 

27 デフォルトの名無しさん [sage] Date:2009/02/28(土) 05:09:07  ID: Be:
    俺はN88-BASICだった
    興味があったというよりそれ以外に身近になかったな 

28 デフォルトの名無しさん [sage] Date:2009/02/28(土) 08:36:32  ID: Be:
    身近に使える言語なら何でもいいよな、正直。
    とりあえず、その言語でプログラムを作りまくれと。

■_ shibuya.lisp TT#2

ダメだ。時間がねー(ただいま 4:25am)。 3/1分で何とか。

2009年02月27日

■_

・にがつはにげる
いやもう書くに書けないことがいろいろと。

・今日のなつたん駆動読書
6ページくらい。

・Let it be
http://www.youtube.com/watch?gl=JP&v=XHosLhPEN3k

■_ redditに訊け: ××が偉大なプログラマー/開発者を作る (What makes a great software developer/programmer?)

面白く訳をつけるのはむずかすぃ。 削った中にも面白いものはあるので、興味のある向きは元記事も是非。


What makes a great software developer/programmer? : programming

anyone who has dared to learn erlang or haskell for the sheer intention of becoming a 
better programmer

anyone who selfishly does it for "fun" and not just the pay cheque

I'm surprised nobody has mentioned it yet:
It's the beard.

:D In a similar vein:
http://www.folklore.org/StoryView.py?project=Macintosh&story=Moustache.txt&sortOrder=Sort%20by%20Date&detail=medium

some developers who think they're great like to show off their knowledge by using 
arcane or overly complicated features of a language. but this makes their software 
difficult for others to maintain.

i'd say a quality of a great developer is:

    * they write software other people can understand.

I think it's more complicated than that:

    * They write elegant code quickly

Where 'elegant' is the simplest solution that exactly fulfills a given requirement.

A talent for coming up with simple solutions to complex problems.
Here's what I've seen in some of the software developers I respect:

    * lots of experience writing, reading and maintaining code
    * proficiency in many different languages in many different paradigms
    * an understanding of computer systems - how modern CPUs are architected, how OSes 
      allocate pages, what kind of bug could be because a compiler generated the wrong
      code, etc ...
    * a reasonable amount of theoretical knowledge in computer science
    * a fairly large toolbox of algorithms to choose from
    * some experience programming in assembly language
    * understanding scalability issues - both complexity scaling and performance scaling
    * and most importantly, the willingness to share with others his/her wisdom, 
      communicate clearly and the willingness to learn

Also they were all really nice people. Maybe that's a requirement too? :-)

On that last point: Communication skills are so often underrated, but SOOO important.

The best developers don't just have the ability to write clean code and read the 
convoluted stuff; they also have the ability to breed those skills in others.

Yup, I've found mentoring junior developers to really help me grow as a developer as 
well. Sometimes you learn a specific path with a technology and it's really helpful to 
see how other people view it and to try to answer the questions they ask - it makes 
you both better.

Passion. (情熱)

taste (経験)

caffeine? (カフェインじゃね?)

Love.

You need to love programming.

People who love programming take in everything that they possibly can about it. They 
remember things that they learn, even if they aren't immediately applicable to the 
problem at hand.

People who don't love programming, who view it as just a job, only learn what they 
need to learn in order to finish the job they are working on. They skip any other gems 
or good ideas that they may run across in the process. Therefore, when they are 
working on another job, where one of those gems might be useful, they don't have it. 
This may slow them down or make their code more cumbersome.

I think that love of programming is necessary, but not sufficient, for greatness at it.
An understanding that writing code is not the most difficult part of 
software development in most cases.
   1. Knows UNIX. Even if they don't develop for it.
   2. Knows at least a dozen languages (C/C++ is always among them even if they don't
      currently actively develop in them).
   3. Write code that are proud of and that is readable and maintainable by others.
   4. Uses time proven tools to do the job.
   5. Knows VIM/Emacs and knows regular expressions and uses them when ever possible.
   6. Can touch type (you'd be surprised how many programmers can't).
   7. Has a degree in CS/math.
Using vim
write robust code while finding the sweet spot between best practices and real-world 
delivery times
brilliant algorithms and good coding skills make a person a good programmer

■_ Why is the DOS path character "\"? (なぜDOSのパスキャラクターは“\”なのか?)

reddit経由で。

Larry Osterman's WebLog : Why is the DOS path character "\"?
Why is the DOS path character "\"?
(なぜDOSのパスキャラクターは“\”なのか?)

Many, many months ago, Declan Eardly asked why the \ character was chosen as the path 
separator.
何十ヶ月も前のことですが、Declan Eardly はなぜ \ がパスのセパレーターとして
選ばれたのかということを尋ねていました。

The answer's from before my time, but I do remember the original reasons.
わたしのところに来るまでに答えは出たのですが、わたしは元々の理由を思い出しました。

It all stems from Microsoft's relationship with IBM.  For DOS 1.0, DOS only supported 
floppy disks.

すべての stem は Microsoft の IBMとの間の関係から来たのです。
DOSの1.0では、フロッピーディスクだけがサポートされていました。


Many of the DOS utilities (except for command.com) were written by IBM, and they used 
the "/" character as the "switch" character for their utilities 
(the "switch" character is the character that's used to distinguish command 
line switches - on *nix, it's the "-" character, on most DEC operating 
systems (including VMS, the DECSystem-20 and DECSystem-10), it's the "/" 
character" (note: I'm grey on whether the "/" character came from IBM 
or from Microsoft - several of the original MS-DOS developers were old-hand DEC-20 
developers, so it's possible that they carried it forward from their DEC background).

多くのDOSユーティリティ(command.comを除きます)はIBMによって作られたもので、
それらはオプション指定のための“スイッチ”として“/”を使っていたのです。
これは、ユーティリティの対象となるファイル名などとオプションを区別するためのもので
Unixでは “-”を使っていましたし、DECのほとんどのシステム
(VMSやDEC System-20、DEC System-10などなど)では“/”を使っていました。
“/”を選択することに決めたのがIBMなのかMicrosoftなのかはわたしにはわかりません。
ただ、MS-DOSの開発にかかわったオリジナルメンバーのうちの何人かはDEC-20での経験があったので
その人たちが DEC文化を持ち込んだのかもしれません。


The fact that the "/" character conflicted with the path character of 
another relatively popular operating system wasn't particularly relevant to the 
original developers - after all, DOS didn't support directories, just files in a 
single root directory.

“/”が another relatively popular operating system のパスキャラクターと
ぶつかってしまうということはオリジナルの開発者たちにとっては問題にはなりませんでした。
なぜなら、DOSは階層ディレクトリをサポートしておらず、ルートディレクトリにだけ
ファイルが置かれるものだったからです。

Then along came DOS 2.0.  DOS 2.0 was tied to the PC/XT, whose major feature was a 10M 
hard disk.  IBM asked the Microsoft to add support for hard disks, and the MS-DOS 
developers took this as an opportunity to add support for modern file APIs - they 
added a whole series of handle based APIs to the system (DOS 1.0 relied on an 
application controlled structure called an FCB).  They also had to add support for 
hierarchical paths.

さて、その後 DOS 2.0がやってきました。
DOS 2.0 は10メガバイトのハードディスクを備えていたPC/XT と結び付けられてしました。
IBM は Microsoftに対してハードディスクのサポートを要求し、
MS-DOS開発者たちは近代的なファイルAPIのサポートを追加してこれに対処しました。
彼らが追加したのは一連のハンドルベースのAPIでした
(DOS1.0ではアプリケーションが制御するFCBと呼ばれる構造体に依存していました)。
同時に彼らは階層パスのサポートも追加したのです。

Now historically there have been a number of different mechanisms for providing 
hierarchical paths.  The DecSystem-20, for example represented directories as: 
"<volume>:"<"<Directory>[.<Subdirectory>">"FileName.Extension[,Version]"
("PS:<SYSTEM>MONITR.EXE,4").
VMS used a similar naming scheme, but instead of < and > characters it used [ and ]
(and VMS used ";" to differentiate between versions of files).  *nix defines 
hierarchical paths with a simple hierarchy rooted at "/" - in *nix's naming 
hierarchy, there's no way of differentiating between files and directories, etc (this 
isn't bad, btw, it just is).

歴史的に見ると、階層パスを実現するための機構としていくつかの異なる手段が存在していました。
たとえば DecSystem-20 を例に取るとディレクトリは
"<volume>:"<"<Directory>[.<Subdirectory>">"FileName.Extension[,Version]"
("PS:<SYSTEM>MONITR.EXE,4").
のように表現されました。VMS でも同じような手法が採られていましたが
< と > ではなく [ と ] が使われました
(それに加えてVMSではファイルのバージョンを区別するためのものとして";"を使いました)。
Unix では階層パスを “/”を根とする単純な構成としました。
Unix 流の名称階層ではファイルとディレクトリその他とを(名前だけから)区別する手段がありませんでした
(そのこと自体はそう悪いことではありません。) 。


For MS-DOS 2.0, the designers of DOS chose a hybrid version - they already had support 
for drive letters from DOS 1.0, so they needed to continue using that.  And they chose 
to use the *nix style method of specifying a hierarchy - instead of calling the 
directory out in the filename (like VMS and the DEC-20), they simply made the 
directory and filename indistinguishable parts of the path.

MS-DOS 2.0 のために DOSの設計者たちはハイブリッドバージョンを選択しました。
DOS 1.0でドライブ文字をすでにサポートしていましたから、
彼らにはそれを使いつづけることが必要とされていました。
そしてDOS開発者たちは階層を特定するのに Unix形式の手法を使うことを選択したのです。
VMS や DEC-20 のように
calling the directory out in the filename
とするのではなくただ単純に、ディレクトリとファイル名とを区別できないパスのパーツ
としたのでした。

But there was a problem.  They couldn't use the *nix form of path separator of 
"/", because the "/" was being used for the switch character.

しかしそこに問題があったのです。
彼らはUnix形式のパスセパレーターである“/”を使うことができなかったのです。
なぜならそれは、“/”がすでにオプションスイッチのためのキャラクターとして
使われてしまっていたからです。

So what were they to do?  They could have used the "." character like the 
DEC machines, but the "." character was being used to differentiate between 
file and extension.  So they chose the next best thing - the "\" character, 
which was visually similar to the "/" character.

そこで彼らはどのようにしたのでしょうか?
彼らは DEC machines のように "." を使うことも可能でしたが、
"." はファイルと拡張子との間に置かれてその両者を分けるために
使われてしまっていたのです。というわけで彼らは次善の策を採ったのです。
それこそが "\" を使うというものであり、なんとなれば
"/" に見た目が似ていたのです。


And that's how the "\" character was chosen.

そしてこれこそが“\”が選択された理由なのです。

Here's a little known secret about MS-DOS.  The DOS developers weren't particularly 
happy about this state of affairs - heck, they all used Xenix machines for email and 
stuff, so they were familiar with the *nix command semantics.  So they coded the OS to 
accept either "/" or "\" character as the path character (this 
continues today, btw - try typing "notepad c:/boot.ini"  on an XP machine 
(if you're an admin)).  And they went one step further.  They added an undocumented 
system call to change the switch character.  And updated the utilities to respect this 
flag.

ここでMS-DOSのあまり知られていない秘密を披露しましょう。
DOSの開発者たちは particularly happy about this state of affairs 
開発者たちは全員電子メールや事務のために Xenix マシンを使っていましたから
彼らはUnixのコマンド指定に慣れ親しんでいました。
そして彼らは "/" と "\" のどちらもパスキャラクターとして
受け付けるようにOSを変えてしまったのです
(この機能は今日に到るまで生きつづけています。もしあなたが管理者権限を持っていたなら
XPマシンで "notepad c:/boot.ini"  と入力してみてください)。
さらに彼らはもう一ステップ進みました。
彼らはスイッチキャラクターを切り替えるためのドキュメントに記載されていない
システコールを追加し、そしてユーティリティがこのフラグを見るように変更したのです。


And then they went and finished out the scenario:  They added a config.sys option, 
SWITCHAR= that would let you set the switch character to "-".

And then they went and finished out the scenario:
config.sys にスイッチキャラクターを “-”に設定する
SWITCHAR というオプションを追加したのです。

Which flipped MS-DOS into a *nix style system where command lines used 
"-switch", and paths were / delimited.

このオプションによってMS-DOS はコマンドライン上で "-switch", を使い、
パスが / で区切られるUnix形式のシステムへと切り替わりました。


I don't know the fate of the switchar API, it's been long gone for many years now.

switchar APIの運命をわたしは知りません。それがなくなってしまってからもう何年もたっていますから。

So that's why the path character is "\".  It's because "/" was taken.

パスキャラクターが“\”である理由、それは“/”に先約があったからなのです。

Edit: Fixed title - it's been bugging me all week.

 

コメント欄からいくつか。

 Comments
# re: Why is the DOS path character &amp;quot;\&amp;quot;?
Friday, June 24, 2005 3:28 PM by vince

For a similar article see entry III.15 in this http://netwhatever.com/faq/inicio.html

Also to note, / was a common command-line-option indicator in CP/M, and QDOS (which
Dos1 was of course based off of) was very much a clone of CP/M.

Just wondering about a little detail here:
"For MS-DOS 2.0, the designers of DOS chose a hybrid version - they already had 
support for drive letters from DOS 1.0, so they needed to continue using that."

Where did the drive letters come from, then? I really hate them :) Happily I can, and 
do, use junctions points now, but you still need to have at least one left. It's so 
much cleaner with the unified filesystem :) And it is easier to discover special files 
like the CON, NUL, LPT devices when you can just do dir /devices or something like that.
Drive letters came about (at least to my understanding) because the first PCs 
supported two disk drives.

At the time assigning them letters solved the problem of how to access them. A: for 
the first drive, B: for the second. When the Hard drive came out it was given drive 
letter C: because it was the next in line.

> Where did the drive letters come from, then?

Why CP/M of course, which QDOS (and hence DOS 1) was a clone of. Read the first 
chapter of http://www.iso.port.ac.uk/~mike/interests/chistory/documents/cpm-22-manual/ 
here to see where DOS's real heritage lies... 
> And where did CPM get them from? The DEC operating systems I mentioned above.

I thought the question was about drive letters specifically.

An RSX-11 file path looks like DR0:[30,12]FILE.TXT;10

A CP/M file path for a file on the first floppy looks like
A:PROGRAM.COM

Tim Patterson who wrote QDOS (the basis for DOS 1) did it based on a CP/M manual. I've 
never heard it mentioned that he spent any time on any DEC machines.

There's nothing wrong with DOS originally being a clone of CP/M (similar to how Linux 
started out as a clone of U*IX), I just think people often gloss over the history.

My favorite Gary Kildall quote on the issue:"Ask Bill [Gates] why the string in 
function 9 is terminated by a dollar sign. Ask him, because he can't answer, only I 
know that."
several more tidbits to this story:

IBM made us chose a path separator that was unshifted on the original PC keyboard. Tim 
and Z and friends chose "\" because most of the other unshifted characters already had 
meaning to command.com. there was lots of discussion at the time about ":" for example, 
which was used in some other heirarchical file systems. it's the drive separator but 
not hard to disambiguate. IBM nixed it because it requires a shift key to type.

the mechanism that became "SWITCHAR" was originally put in because they wanted to 
prove that it would be easy to disambiguate the path separation function from the 
command line switch function. this was entirely correct and nearly all command line 
apps support both "-" and "/" seamlessly. but IBM refused to buy it.

Much effort was made to keep the fact that SWITCHAR was in shipping systems a secret 
because it was suspected that when IBM found out they would make us take it out. this 
suspicion was proven correct. It took them almost 5 years to find it though, and none 
of the original DOS crew was still working on it. Eric made the change, as I recall.

the Tops-10 ==> CP/M ==> DOS genealogy someone else mentioned is correct. 
Tops-20 was very late in the story and not really relevant. 

reddit も順調にスレッド?が伸びてます。 Why is the DOS path charater "\"? : programming

■_ 本日の巡回から

米国でRuby関連書籍の売り上げが減速か - @IT

ほかに注目すべき動向としては、売り上げ部数が2000部以下の、ごくマイナーな分類の書籍の売
り上げが伸びていること。このジャンルには「Alice」「Haskell」「F#」などが入っていて、
ヘンドリクソン氏は関数型言語が普及期にさしかかるにつれて、こうした書籍の売り上げが成長
しているとしている。このほか、ややマイナーという分類では、Lua(2400部→1万1000部)、
Processing(2000部→8700部)などが成長の注目株だ。
Last week London.pm organised a technical meetings themed along the question
"What is Moose and why is it the future?". 
http://use.perl.org/~acme/journal/38554
http://london.pm.org/tech_talks/

Win32 console processes in VISTA - 10% CPU, but VERY SLOW - Stack Overflow
http://stackoverflow.com/questions/296520/win32-console-processes-in-vista-10-cpu-but-very-slow

What is the purpose of null? - Stack Overflow
http://stackoverflow.com/questions/584507/what-is-the-purpose-of-null

What non-programming books should programmers read? - Stack Overflow
http://stackoverflow.com/questions/38210/what-non-programming-books-should-programmers-read
http://stackoverflow.com/questions/38210?sort=votes&page=2#sort-top
http://stackoverflow.com/questions/38210?sort=votes&page=3#sort-top
http://stackoverflow.com/questions/38210?sort=votes&page=4#sort-top
http://stackoverflow.com/questions/38210?sort=votes&page=5#sort-top
http://stackoverflow.com/questions/38210?sort=votes&page=6#sort-top

■_

ちと日付が前ですが。

組み込みプログラマー雑談スレッド その11 

237 仕様書無しさん [sage] Date:2009/02/10(火) 18:08:34  ID: Be:
    横文字並べるだけの奴はダメだ。実際に8ビットあたりで自由自在に組めるレベルなら
    何ビットになっても大丈夫だし、でなければどこでも使えない。

    C言語すら知らないなら、末端評価者に落とされるよ。 

238 仕様書無しさん [sage] Date:2009/02/10(火) 18:37:05  ID: Be:
    最大の敵はハード屋だってことにその内気がつくだろ。

    ほーれあたまおさえにかかってる 

239 仕様書無しさん [sage] Date:2009/02/10(火) 18:39:03  ID: Be:
    >>238
    ハード屋さんはお友達だよ。
    時々回路間違ってるの教えてあげると喜んでくれるし。 

240 仕様書無しさん [sage] Date:2009/02/10(火) 18:42:46  ID: Be:
    >>239
    そうか? verilog のソースの間違い指摘したら、いやな顔されたぞ。

241 仕様書無しさん [sage] Date:2009/02/10(火) 18:47:32  ID: Be:
    ハード仕様出来上がってないのにソフト書け。
    書いてれば「仕様も決まってないんだからそんなの絵空事だよな」
    中身チェックするかと問えば「そっちは好きにやってくれ」

    で、このご時世減俸だの首だの脅迫されて毎日過ごしてますよ。

242 仕様書無しさん [sage] Date:2009/02/10(火) 18:50:22  ID: Be:
    >>240
    そーでもないよ。
    この前は石に電源入ってないの教えてあげたら
    ダッシュで部屋に戻っていったよ。試作流す寸前
    だったらしいw 

243 仕様書無しさん [sage] Date:2009/02/10(火) 18:53:53  ID: Be:
    へぼってどこにでもいるのな。
    でも威張り散らさないんならうらやましいねえ。 

244 仕様書無しさん [sage] Date:2009/02/10(火) 18:54:54  ID: Be:
    >>243
    あとから1000枚くらいジャンパする手間考えたら
    少しくらい御礼言われてもいいんじゃないかと思ったよ。 

245 仕様書無しさん [sage] Date:2009/02/10(火) 18:57:12  ID: Be:
    >>242
    > この前は石に電源入ってない
    そんなもん寄越す時点で論外だろwW

246 仕様書無しさん [sage] Date:2009/02/10(火) 18:58:01  ID: Be:
    >>245
    そんなものだよ試作なんて。
    分かり合うことが大切なんだなぁ。 

247 仕様書無しさん [sage] Date:2009/02/10(火) 19:04:13  ID: Be:
    両方やってるけど、石に電源入ってない物渡したら
    いくら試作だからって、しばらく当分立ち直れないwW

248 仕様書無しさん [] Date:2009/02/10(火) 19:05:11  ID: Be:
    そんなんで徹夜とか残業とかうっかりすると怪我の危険はごめんだよ。
    ハード屋は威張り散らすならそれだけの仕事しろ。
    それができないなら威張るな、俺が概要設計してやるからそのとおり作れ。

    一遍はっきり言ってみたいわ。 

249 仕様書無しさん [sage] Date:2009/02/10(火) 19:06:38  ID: Be:
    にんげんだもの。

    みつを 

250 仕様書無しさん [sage] Date:2009/02/10(火) 21:31:37  ID: Be:
    >>248
    えっとね、俺はおそらく昔のハード屋になるんだと思う
    でね、少なくとも、必ず乗っかるOSのデバドラマでは
    絶対に書く。それがRTOSのもので動こうが、Windows で
    動こうか、*nix で動こうかだ!

    つか、自分で作ったものがその通りに動かないのが一番悲しい

251 仕様書無しさん [sage] Date:2009/02/10(火) 21:48:08  ID: Be:
    自分で作ろうとしたものが、すったもんだの挙句
    まったく古いものに置き換わっていた。

    そんな悲しい酒を飲んでおります。
    まあ会社自体危ないんだけどね。 

252 仕様書無しさん [sage] Date:2009/02/10(火) 21:49:10  ID: Be:
    >>251
    父さん? 

253 仕様書無しさん [sage] Date:2009/02/10(火) 21:54:34  ID: Be:
    そういうシリアスねたはやめとこう。w 

254 仕様書無しさん [sage] Date:2009/02/10(火) 21:56:45  ID: Be:
    >>253
    シリアス大好き 

255 仕様書無しさん [sage] Date:2009/02/10(火) 21:58:43  ID: Be:
    そこはシリアルだろ 

256 仕様書無しさん [sage] Date:2009/02/10(火) 21:59:05  ID: Be:
    >>255
    いや、パラで。 

257 仕様書無しさん [sage] Date:2009/02/10(火) 22:15:28  ID: Be:
    今時パラはないと思う

260 仕様書無しさん [] Date:2009/02/11(水) 00:27:29  ID: Be:
    >>257
    メモリIFは未だにパラだよ 

261 仕様書無しさん [sage] Date:2009/02/11(水) 16:49:59  ID: Be:
    フラッシュはシリアルだろ。

262 仕様書無しさん [sage] Date:2009/02/11(水) 19:09:41  ID: Be:
    はいはいわろす(AAry 

263 仕様書無しさん [sage] Date:2009/02/11(水) 19:11:42  ID: Be:
    昔シリアルばっかしで栄養失調ぎみになった。 

265 仕様書無しさん [sage] Date:2009/02/11(水) 23:08:32  ID: Be:
    スパンション・・。 

267 仕様書無しさん [sage] Date:2009/02/12(木) 19:41:26  ID: Be:
    >>265

    それでなくても人減らされてて忙しいのに、
    今日flashROM品番変更の連絡が来た。

    めんどくせーーー 

268 た [sage] Date:2009/02/12(木) 19:48:26  ID: Be:
    >>267
    それ俺やるよ。 

269 仕様書無しさん [sage] Date:2009/02/12(木) 23:18:59  ID: Be:
    >>267,268
    普通ソースコード中のテーブル書き換えておわらんか?

270 仕様書無しさん [] Date:2009/02/13(金) 01:10:48  ID: Be:
    業界によっては型番変更が大作業になるところもある・・・ 

271 仕様書無しさん [sage] Date:2009/02/13(金) 06:58:31  ID: Be:
    えぇ、中身同じで型番だけ少し変わるだけでもすったもんだですよ。 

274 仕様書無しさん [sage] Date:2009/02/13(金) 19:11:14  ID: Be:
    通信のバグ取りって大変だよな。 

275 仕様書無しさん [sage] Date:2009/02/14(土) 00:00:47  ID: Be:
    通信のはバグより例外処理の山になる方が多い。 

276 仕様書無しさん [sage] Date:2009/02/14(土) 00:27:31  ID: Be:
    LINとかCANて使ったことある人いる?
    中距離(数m~十数m)通信って何つかったらいいですか?
    LANが使えない状況だとして 

277 仕様書無しさん [sage] Date:2009/02/14(土) 00:50:56  ID: Be:
    男はだまってシリアル 

278 仕様書無しさん [sage] Date:2009/02/14(土) 02:05:21  ID: Be:
    232は公式には5mまでだけど、十数mならたいてい使える。それでダメなら422でいいんじゃ? 

279 仕様書無しさん [sage] Date:2009/02/14(土) 02:14:11  ID: Be:
    ペリフェラル次第。
    uartでいいじゃんな。 

280 仕様書無しさん [sage] Date:2009/02/14(土) 07:23:32  ID: Be:
    無手順で無応答になるわけですね、わかります。 

281 仕様書無しさん [sage] Date:2009/02/14(土) 09:28:23  ID: Be:
    CANの低速verと高速verで違うし、でもCANはお勧め。 

マ板でも何気に濃い話が出るんだよなあw

2009年02月26日

■_

・core
ruby-core で Yet Another Selector Namespace Proposal のスレッドがえらい伸びてるなあ

・本日のなつたん駆動読書
進捗なし。やばい。イキナリ三日坊主コースか?

■_ 本日の巡回から

◆What is the purpose of null?
http://stackoverflow.com/questions/584507/what-is-the-purpose-of-null

What non-programming books should programmers read?
http://stackoverflow.com/questions/38210/what-non-programming-books-should-programmers-read

◆What does I18N safe mean?2009/2/26 08:27
http://stackoverflow.com/questions/586973/what-does-i18n-safe-mean

最後のi18nのはなんかかたすかしーw

■_ さすが統計用言語だw

28人中にB型が3名以下になる確率 - sumim’s smalltalking-tos

28人中にB型が3名以下になる確率 - sumim’s smalltalking-tos

くけー 2009/02/25 18:27

> pbinom(3,28,0.2)
[1] 0.1601827

まあそのとおりなんですが、それで済ませてはR(を使ったプログラミング) の勉強にならなかったということで一つ。

Binomial(stats) R Documentation 

The Binomial Distribution

Description

Density, distribution function, quantile function and random generation for the 
binomial distribution with parameters size and prob. 

Usage
dbinom(x, size, prob, log = FALSE)
pbinom(q, size, prob, lower.tail = TRUE, log.p = FALSE)
qbinom(p, size, prob, lower.tail = TRUE, log.p = FALSE)
rbinom(n, size, prob)

Arguments
x, q vector of quantiles. 
p vector of probabilities. 
n number of observations. If length(n) > 1, the length is taken to be the number required. 
size number of trials (zero or more). 
prob probability of success on each trial. 
log, log.p logical; if TRUE, probabilities p are given as log(p). 
lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]. 

Details

The binomial distribution with size = n and prob = p has density 

p(x) = choose(n,x) p^x (1-p)^(n-x)

for x = 0, ..., n. 

If an element of x is not integer, the result of dbinom is zero, with a warning. p(x) 
is computed using Loader's algorithm, see the reference below. 

The quantile is defined as the smallest value x such that F(x) >= p, where F is the 
distribution function. 

Value

dbinom gives the density, pbinom gives the distribution function, qbinom gives the 
quantile function and rbinom generates random deviates. If size is not an integer,
NaN is returned.

Source

For dbinom a saddle-point expansion is used: see 

Catherine Loader (2000). Fast and Accurate Computation of Binomial Probabilities; 
available from http://www.herine.net/stat/software/dbinom.html. 

pbinom uses pbeta. 

qbinom uses the Cornish–Fisher Expansion to include a skewness correction to a normal 
approximation, followed by a search. 

rbinom (for size < .Machine$integer.max) is based on 

Kachitvichyanukul, V. and Schmeiser, B. W. (1988) Binomial random variate generation. 
Communications of the ACM, 31, 216–222. 

See Also
dnbinom for the negative binomial, and dpois for the Poisson distribution. 

Examples
require(graphics)
# Compute P(45 < X < 55) for X Binomial(100,0.5)
sum(dbinom(46:54, 100, 0.5))

## Using "log = TRUE" for an extended range :
n <- 2000
k <- seq(0, n, by = 20)
plot (k, dbinom(k, n, pi/10, log=TRUE), type='l', ylab="log density",
      main = "dbinom(*, log=TRUE) is better than  log(dbinom(*))")
lines(k, log(dbinom(k, n, pi/10)), col='red', lwd=2)
## extreme points are omitted since dbinom gives 0.
mtext("dbinom(k, log=TRUE)", adj=0)
mtext("extended range", adj=0, line = -1, font=4)
mtext("log(dbinom(k))", col="red", adj=1)


  

以上はRのマニュアルから。 d, p, q, r って接頭辞? がよくわからん。 二項分布 - Wikipedia は忘れてたなあ。いかんいかん。

■_ 比較

入出力とかプロセス起動とかはないので、あまり影響は出てないだろうなあと思いつつ。 cygwin, mingw, vc7.1 でフィボナッチ数列の計算するやつで比較。

bash-3.2$ time ./fibmin 40
102334155

real    0m3.563s
user    0m0.015s
sys     0m0.015s
bash-3.2$ time ./fibmin 40
102334155

real    0m3.594s
user    0m0.015s
sys     0m0.015s
bash-3.2$ time ./fibmin 40
102334155

real    0m3.922s
user    0m0.031s
sys     0m0.000s
bash-3.2$ time ./fibcyg 40
102334155

real    0m4.078s
user    0m2.811s
sys     0m0.015s
bash-3.2$ time ./fibcyg 40
102334155

real    0m3.921s
user    0m2.812s
sys     0m0.000s
bash-3.2$ time ./fibcyg 40
102334155

real    0m4.141s
user    0m2.827s
sys     0m0.015s
bash-3.2$ time ./fibvc 40
102334155

real    0m3.797s
user    0m0.015s
sys     0m0.015s
bash-3.2$ time ./fibvc 40
102334155

real    0m3.984s
user    0m0.015s
sys     0m0.015s
bash-3.2$ time ./fibvc 40
102334155

real    0m3.766s
user    0m0.015s
sys     0m0.015s
bash-3.2$

やっぱ倍とかのレベルでは違いでないよなあ。

■_


Linus「C++プログラマはウンコ。寄ってくるな」 2
377 デフォルトの名無しさん [] Date:2009/02/26(木) 14:37:30  ID: Be:
    素人は
    他人のアラだけ
    よく見える 

おお、ちゃんと5・7・5になってる。



Linus「C++プログラマはウンコ。寄ってくるな」 2 

279 デフォルトの名無しさん [] Date:2009/02/21(土) 23:24:42  ID: Be:
    C/C++ カレーはご飯とルーに分けて食べるタイプ
    Objective-C カレーはご飯とルーをぐちゃぐちゃに混ぜてから食べるタイプ 

281 デフォルトの名無しさん [sage] Date:2009/02/21(土) 23:27:04  ID: Be:
    >>279
    違うだろ
    カレー(C)に福神漬け(オブジェクト指向)を乗せたのがObjective-C
    カレーの具に福神漬けを入れて煮込んじゃったのがC++ 

282 デフォルトの名無しさん [sage] Date:2009/02/21(土) 23:46:04  ID: Be:
    カレー→シーフードカレー的進化がC++、
    カレー→エビフライカレー的進化がObjective-C。

    後者は、乗っかってるエビフライのビジュアルに問題がある。 

285 デフォルトの名無しさん [sage] Date:2009/02/22(日) 05:41:21  ID: Be:
    イメージとしてはこうかな
    Objective-C  カレーソースとライスが分かれてる(上品な感じ)
    C++       カレーうどん(大衆的な感じ) 

286 デフォルトの名無しさん [sage] Date:2009/02/22(日) 10:20:21  ID: Be:
    Objective-C: ご飯の上にカレーうどん用のカレーぶっかけちゃった感じ
    C++ ご飯に普通のカレー入れたけど、ぐちゃぐちゃにかき混ぜちゃった 

287 デフォルトの名無しさん [sage] Date:2009/02/22(日) 10:47:12  ID: Be:
    大阪にはご飯の入ったカレーうどんがあるんだぞ 

よくわからない流れだ。 しかし大阪。なんて恐ろしいw

2009年02月25日

■_

・今日のなつたん駆動読書
5ページ○| ̄|_

・全体最適
「全体最適」を目指すすばらしい姿勢に[お察しください]

「るくるく」が来月で最終回と。

■_ 今日もRと戯れる

あ、sumimさんにおもいっきりぶっちぎられてるなあ(^^; 2009-02-25 - sumim’s smalltalking-tos

> load("C:\\XXXX\\YYYY\\ZZZZ\\.RData")
> for (i in seq(10)) print(table(sapply(runif(28), fb)))

 A AB  B  O 
13  1  7  7 

 A AB  B  O 
13  3  7  5 

 A AB  B  O 
 9  4  4 11 

 A AB  B  O 
12  2  8  6 

 A AB  B  O 
13  3  8  4 

 A AB  B  O 
10  7  4  7 

 A AB  B  O 
11  2  6  9 

 A AB  B  O 
 7  3  3 15 

 A AB  B  O 
17  2  3  6 

 A AB  B  O 
14  2  4  8 
> for (i in seq(10)) xx[i] <- (table(sapply(runif(28), fb)))
 以下にエラー xx[i] <- (table(sapply(runif(28), fb))) : 
   オブジェクト "xx" は存在しません 
> xx <- vector(mode="list", length=10)
> for (i in seq(10)) xx[i] <- (table(sapply(runif(28), fb)))
Warning messages:
1: In xx[i] <- (table(sapply(runif(28), fb))) :
   置き換えるべき項目数が,置き換える数の倍数ではありませんでした 
2: In xx[i] <- (table(sapply(runif(28), fb))) :
   置き換えるべき項目数が,置き換える数の倍数ではありませんでした 
3: In xx[i] <- (table(sapply(runif(28), fb))) :
   置き換えるべき項目数が,置き換える数の倍数ではありませんでした 
4: In xx[i] <- (table(sapply(runif(28), fb))) :
   置き換えるべき項目数が,置き換える数の倍数ではありませんでした 
5: In xx[i] <- (table(sapply(runif(28), fb))) :
   置き換えるべき項目数が,置き換える数の倍数ではありませんでした 
6: In xx[i] <- (table(sapply(runif(28), fb))) :
   置き換えるべき項目数が,置き換える数の倍数ではありませんでした 
7: In xx[i] <- (table(sapply(runif(28), fb))) :
   置き換えるべき項目数が,置き換える数の倍数ではありませんでした 
8: In xx[i] <- (table(sapply(runif(28), fb))) :
   置き換えるべき項目数が,置き換える数の倍数ではありませんでした 
9: In xx[i] <- (table(sapply(runif(28), fb))) :
   置き換えるべき項目数が,置き換える数の倍数ではありませんでした 
10: In xx[i] <- (table(sapply(runif(28), fb))) :
   置き換えるべき項目数が,置き換える数の倍数ではありませんでした 
> dd <- list(list(table(sapply(runif(28), fb))), list(table(sapply(runif(28), fb))))
> dd
[[1]]
[[1]][[1]]

 A AB  B  O 
12  2  3 11 


[[2]]
[[2]][[1]]

 A AB  B  O 
10  3  6  9 


> dd[1]
[[1]]
[[1]][[1]]

 A AB  B  O 
12  2  3 11 


> dd[2]
[[1]]
[[1]][[1]]

 A AB  B  O 
10  3  6  9 


> dd <- list((table(sapply(runif(28), fb))), (table(sapply(runif(28), fb))))
> dd
[[1]]

 A AB  B  O 
12  3  2 11 

[[2]]

 A AB  B  O 
17  3  4  4 

> ddd[1]
[[1]]

 A AB  B  O 
12  3  2 11 

> ddd[2]
[[1]]

 A AB  B  O 
17  3  4  4 

> z<-list(0)
> z
[[1]]
[1] 0

> z<-list(10)
> z
[[1]]
[1] 10

> 
> 
> z<-vector("list", 5)
> z
[[1]]
NULL

[[2]]
NULL

[[3]]
NULL

[[4]]
NULL

[[5]]
NULL

> for (i in seq(5)) z[i] <- list((table(sapply(runif(28), fb))))
> z
[[1]]

 A AB  B  O 
 9  4  6  9 

[[2]]

 A  B  O 
11  6 11 

[[3]]

 A AB  B  O 
13  4  2  9 

[[4]]

 A AB  B  O 
15  4  3  6 

[[5]]

 A AB  B  O 
10  5  7  6 

> z[1]
[[1]]

 A AB  B  O 
 9  4  6  9 

> sum(z[1])
 以下にエラー sum(z[1]) :  引数 'type' (list) が不正です 
> sum(unlist(z[1]))
[1] 28
> 

なんとなくRのデータの扱い方がわかってきたような気がする。 とはいえ、vector, array, list などが別物というのがよくわかんね。 まあ Python でも list と tuple 別物だしなあ。

■_ 今日の巡回から

■_ ム板ヲチ


C++相談室 part66
128 デフォルトの名無しさん [sage] Date:2009/02/21(土) 17:50:44  ID: Be:
    テンプレートの使い方で分からないんだけど、
    template <typename T>
    class Myclass
    {
    public:
    T mem;
    //他、Tを使ったメンバ関数・メンバ変数が多数
    int foo(int x){std::cout << x << std::endl;return x;}
    double foo(double x){std::cout << x << std::endl;return x;};
    unsigned long foo(unsigned long x){std::cout << x << std::endl;return x;};
    };
    のようなクラスがあって、呼び出すときは
    Myclass<char> hoge;
    hoge.foo((int)-1);
    hoge.foo((double)3.14);
    hoge.foo((unsigned long)42);
    のように使っている状況。
    で、この3つのfooをテンプレートにしてまとめたいんだけど、どうすりゃいいかね??
    template <typename T,typename U>
    class Myclass
    {//~~};
    とは意味合いが違うじゃん。。。 

129 デフォルトの名無しさん [sage] Date:2009/02/21(土) 17:56:51  ID: Be:
    template<typename U>
    U foo(U x){std::cout << x << std::endl;return x;}
    をメンバにすればいいだけじゃないの 

130 デフォルトの名無しさん [sage] Date:2009/02/21(土) 18:03:02  ID: Be:
    >>128
    できた。
    テンプレートの中にテンプレートを入れ子にできるのか。
    ありがとう。

131 128 [sage] Date:2009/02/21(土) 18:26:11  ID: Be:
    今度はコンストラクタで死んだ。
    template <typename T>
    class Myclass
    {
    public:
    T mem;
    //他、Tを使ったメンバ関数・メンバ変数が多数
    Myclass();
    template<typename T,typename U> Myclass(U x);//コンストラクタ
    };
    template <typename T>
    Myclass<T>::Myclass(){}
    template <typename T,typename U>
    Myclass<T>::Myclass(U x){}

    こうするとbccにて
    テンプレート 'Myclass<T>' に対して宣言されたテンプレートパラメータが多すぎる
    'Myclass<T>::Myclass(U)' は 'Myclass<T>' のメンバーではない
    'Myclass<char>::Myclass(int)' に一致するものが見つからない(関数 main() )
    って言われた。
    int main()
    {
    Myclass<char> hoge;
    Myclass<char> piyo(42);
    return 0;}
    です。
    この場合はどうやって宣言したらいいですか??

132 デフォルトの名無しさん [sage] Date:2009/02/21(土) 19:16:17  ID: Be:
    template<typename U> Myclass(U x); 

133 128 [sage] Date:2009/02/21(土) 19:44:41  ID: Be:
    >>132
    クラス内の定義はそれでいけた。
    クラス外はどうすればいい?
    template <typename T,typename U>
    Myclass<T>::Myclass(U x){}
    だとダメっぽいんだが
    template <typename T>
    template <typename U>
    Myclass<T>::Myclass(U x){}
    にしてみたら出来る。
    これで、間違ってない?

134 デフォルトの名無しさん [sage] Date:2009/02/21(土) 20:11:23  ID: Be:
    operatorの使い方で相談です。
    プログラムと相談内容はこちらにまとめて書きました。
    ttp://www.nigauri.sakura.ne.jp/src/up8638.txt 

135 デフォルトの名無しさん [sage] Date:2009/02/21(土) 20:14:52  ID: Be:
    operator+=を作ってそれを使うのがベストじゃね
    というかeffective c++位読んだ方が良い

136 デフォルトの名無しさん [sage] Date:2009/02/21(土) 20:41:12  ID: Be:
    >>133
    順番に考えればいい
    普通のクラスのコンストラクタテンプレートならこう書くだろう

    template <typename U>
    NormalClass::NormalClass(U x){}

    このNormalClassを具体化に置き換えてみる

    template <typename U>
    MyClass<int>::MyClass<int>(U x){}

    テンプレートの規則からコンストラクタ名の方の<int>は省略できる

    template <typename U>
    MyClass<int>::MyClass(U x){}

    このintをテンプレート化すると

    template <typename T> template <typename U>
    MyClass<T>::MyClass(U x){}

    ほらできた 

138 133 [sage] Date:2009/02/21(土) 21:17:33  ID: Be:
    >>136
    ありがとう!!
    template <typename T>template <typename U>
    Myclass<T>::Myclass(U x){}
    なんだけど、これをUの部分だけexplicit instantiationすることは出来る?
    (まあまだ完全にインスタンス化されないからexplicit instantiationとは言わないだろうが。)
    template <typename T>
    class Myclass
    {
    public:
    T mem;
    //他、Tを使ったメンバ関数・メンバ変数が多数
    Myclass();
    template <typename U> Myclass(U x);//コンストラクタ
    template <typename U> U bar(U x);//適当な関数
    };
    この時、一番最後の適当な関数barは
    template <typename T>template <typename U>
    U Myclass<T>::bar(U x){std::cout << x << std::endl;return x;}
    みたいに定義出来ることは>>136に今 教わったことで分かるんだが、このU型の部分をdoubleやintなど既にある型でexplicit instantiation(っぽいこと)しておきたい。
    現状は、現在はヘッダーファイルと実装のソースファイルを分けている状態で、ソースファイルの末尾で
    template class Myclass<char>;
    の様にexplicit instantiationしている。
    この状態でコンストラクタやメンバ関数bar()をまとめてU型でテンプレートにしようとしたら困っているところ。

139 デフォルトの名無しさん [sage] Date:2009/02/22(日) 07:50:29  ID: Be:
    >138
    explicit instantiation (みたいなことを)したい理由は何?
    ライブラリを作ってるとかなら explicit instantiation する意味はあるだろうけど、
    何がしたいのか良く分からない。

    処理系のインスタンス化の実装方法によっては多少コンパイルが効率化されるかもしれないが、
    他の処理系ではむしろ効率が悪化したりするんじゃないだろうか。 

140 138 [sage] Date:2009/02/22(日) 09:26:36  ID: Be:
    >>139
    >>ライブラリを作ってるとかなら explicit instantiation する意味はあるだろうけど、
    ライブラリ作ってる。
    いろんなところで使っている処理なんだ。。。
    そして、ぜーんぶヘッダファイルに実装まで含めてinlineなんてことはしたくない。 

142 138 [sage] Date:2009/02/22(日) 10:58:50  ID: Be:
    Uとしてはint,double,unsigned longを想定する。
    この時とりあえずTがcharな場合しか使わないなら、ライブラリのソースファイルで
    //explicit instantiation<T=char版>
    template class Myclass<char>;
    template Myclass<char>::Myclass<int>(int x);
    template Myclass<char>::Myclass<double>(double x);
    template Myclass<char>::Myclass<unsigned long>(unsigned long x);
    template int Myclass<char>::bar<int>(int x);
    template double Myclass<char>::bar<double>(double x);
    template unsigned long Myclass<char>::bar<unsigned long>(unsigned long x);
    とすれば解決することまでは理解できた。 

143 138 [sage] Date:2009/02/22(日) 10:59:28  ID: Be:
    だが実際にはTがchar以外の場合もあったら、例えばTがstd::stringやwchar_t,std::wstringな場合に、
    上のcharの時の物に加えて
    //explicit instantiation<T=std::string版>
    template class Myclass<std::string>;
    template Myclass<std::string>::Myclass<int>(int x);
    template Myclass<std::string>::Myclass<double>(double x);
    template Myclass<std::string>::Myclass<unsigned long>(unsigned long x);
    template int Myclass<std::string>::bar<int>(int x);
    template double Myclass<std::string>::bar<double>(double x);
    template unsigned long Myclass<std::string>::bar<unsigned long>(unsigned long x);
    のように書かねばならないのだろうか?
    そうだとすると、メンバ関数のexplicit instantiationだけで12行書くことになるよね?
    (Tで4通り、Uで3通りのかけ算として。)
    俺としてはTだけはおいといてU(メンバ関数テンプレート)だけでとりあえず3通りのexplicit instantiation(もどき)なことをしておいて、その後Tを4通りexplicit instantiationできればいいなぁと思っているのだが…。
    たいていこういう場合ってC++だとちゃんと逃げ道あるよね? 

テンプレートを使ってプログラム作れる気がしねえw



【初心者歓迎】C/C++室 Ver.64【環境依存OK】 
176 デフォルトの名無しさん [sage] Date:2009/02/24(火) 15:37:21  ID: Be:
    構造体A(メンバchar a , int b)をsizeofした値を求めろって問題は
    5と8どちらを答えるべきなんですかね。
    パディングも含めた値が実際の答えなのでしょうか? 

177 デフォルトの名無しさん [sage] Date:2009/02/24(火) 15:43:08  ID: Be:
    intのサイズすら環境依存でFA 

178 デフォルトの名無しさん [sage] Date:2009/02/24(火) 16:17:40  ID: Be:
    >>176
    答えはsizeof( A )だろ

179 デフォルトの名無しさん [sage] Date:2009/02/24(火) 19:12:55  ID: Be:
    >>178
    お前まぢ頭いいな 

180 デフォルトの名無しさん [sage] Date:2009/02/24(火) 19:43:18  ID: Be:
    ('A`)に見えた

181 デフォルトの名無しさん [sage] Date:2009/02/24(火) 19:44:54  ID: Be:
    sizeof に目がなくて 

182 デフォルトの名無しさん [sage] Date:2009/02/24(火) 20:08:55  ID: Be:
    sizeof('A`)だと8なのでやはり8が答えみたいですね
    ありがとうございました。 

183 デフォルトの名無しさん [sage] Date:2009/02/24(火) 22:27:13  ID: Be:
    >>182
    俺の環境では5になるんだが 

184 デフォルトの名無しさん [sage] Date:2009/02/24(火) 23:19:58  ID: Be:
    >>182 環境依存
    #include<stdio.h>

    #define MACRO(type) printf("sizeof(%s)=%d\n", #type, sizeof(type))

    #pragma pack(push, 1)
    struct pack1{
    char a;
    int b;
    };
    #pragma pack(pop)

    #pragma pack(push, 2)
    struct pack2{
    char a;
    int b;
    };
    #pragma pack(pop)

    #pragma pack(push, 4)
    struct pack4{
    char a;
    int b;
    };
    #pragma pack(pop)

    int main(void){
    MACRO(struct pack1);
    MACRO(struct pack2);
    MACRO(struct pack4);
    return 0;
    } 

185 デフォルトの名無しさん [sage] Date:2009/02/25(水) 01:13:18  ID: Be:
    なんと…
    処理系依存なのでどれも正解ということですか!
    コードまでご丁寧にありがとうございました。

186 デフォルトの名無しさん [sage] Date:2009/02/25(水) 09:51:49  ID: Be:
    処理系というか、自分で決められるといった方が正しい 

2009年02月24日

■_

・本日のなつたん駆動読書
時間がなくて5ページほど。ときに、練習問題はどうすべきか? やっぱ処理系もインストールしてやっておくべきか。

・本日の購入
某DVDショップで、わたしの前に並んでた人がスカイ・クロラの限定ボックスを買っていた。 いいなあ、金あって。 それはそれとして 日経ソフトウエアとWEB+DB Magazineを購入。 初めてのPython 第3版とかC# 第5版は天候も良くなく荷物が多かったのでとりあえず様子見。 日経の特集(Excelでごにょごにょ)とかWEB+DBの artonさんの記事についてあとで書く。たぶん。
日経ソフトウエア 2009年 03月号 [雑誌]
WEB+DB PRESS Vol.49

■_ → 4.2

Re: sed: suggestions for sed release-management
bug-gnu-utils
[Top][All Lists]
Advanced
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sed: suggestions for sed release-management
From: 	Paolo Bonzini
Subject: 	Re: sed: suggestions for sed release-management
Date: 	Mon, 23 Feb 2009 09:35:30 +0100

Regarding the website, I'll do some (minor) improvements.

> 4) The manpage should mention the symlink problem regarding '-i'.

First, it is not a problem, it's a feature.  Second, the manpage is
directly generated from the --help output (plus the description of the
commands).  It correctly points out that the main source of
documentation is info.

> 5) Releases. The last stable release is sed-4.1.5 from 2006-02-03.
> That's more than 3 years ago. Please consider providing new stable
> releases more regularly. If you think it's not "stable as in stable"
> yet these days, than providing release candidates might be an option.

sed is very close to the next release, which will touch more or less
every point that you mention.  I fixed a couple of known bugs in
January, and will probably start asking for wide testing in 2-3 weeks.
4.2 will be considered mature.  After it stabilizes, I don't plan to
make any additional minor release (only bugfixes) and the git repository
will always be stable.

Paolo

おっと、4.1.5 から 4.1.6 じゃなくて 4.2 ということはそれなりに中身に手が入ってるのか?

■_ (バックトラック回数が)爆発

Ruby 1.8 - Bug #1197: regular expression never finishes - Ruby Issue Tracking System
Bug #1197 [ruby-core:22361]
regular expression never finishes

(略)

説明

'a foobarfoobar foobarfoobar"'.scan(/^(([^"\n]*|"([^"]|"")+")+)($)/m)

I tried with Debian-testing, Gentoo-stable Ruby1.8 and Debian-testing Ruby1.9, the 
results are same: the command never finishes, CPU usage 100%.

Is this a bad regular expression? If it is, how can I know? 

I am neither a master nor a fan of PHP, I just tried it before filing a bug because of 
curiosity:

<?php

$a = preg_split('/^(([^"\n]*|"([^"]|"")+")+)($)/','a foobarfoobar foobarfoobar"');
echo $a[0];

?>

which exits normally. Not in Ruby, with or without the multiline.

regexp.rb (142 Bytes) Péter Szabó, 2009年02月23日 22:01 PM
履歴
#1
2009年02月23日 22:36 PM - Shyouhei Urabe

    * ステータス OpenからRejectedに変更

Exits normally?  On my machine that "echo $a[0];" just prints nothing.
PHP gives up running that script, while ruby tries it anyway.

As you guessed this is a bad regex that backtracks over and over again.
The only way I can think of for you to know which is bad, is to learn
how it works.

#2
2009年02月24日 00:24 AM - Yui NARUSE

Use 'a foobarfoobar foobarfoobar"'.scan(/^([^"\n]*(?:"[^"]*(?:""[^"]*)*")*)$/m)

コメントにもある通りでPHPの preg で問題ないというのはちとわからんなあ。 ereg だったらありえるんだけど。 ひょっとしてPHPのバージョンによって違ってたりして (とはいえpregは実質PCREだしなあ)。

■_ 「エレガント」なコードとは?

stackoverflow から。

What is "elegant" code? - Stack Overflow
I see a lot of lip service and talk about the most "elegant" way to do this 
or that. I think if you spend enough time programming you begin to obtain a sort of 
intuitive feel for what it is we call "elegance". But I'm curious. Even if 
we can look at a bit of code, and say instinctively "That's elegant", or 
"That's messy", I wonder if any of us really understands what that means. Is 
there a precise definition for this "elegance" we keep referring to? If 
there is, what is it?

Now, what I mean by a precise definition, is a series of statements which can be used 
to derive questions about a peice of code, or a program as a whole, and determine 
objectively, or as objectively as possible, whether that code is "elegant" 
or not.

May I assert, that perhaps no such definition exists, and it's all just personal 
preference. In this case, I ask you a slightly different question: Is there a better 
word for "elegance", or a better set of attributes to use for judging code 
quality that is perhaps more objective than merely appealing to individual intuition 
and taste?

Perhaps code quality is a matter of taste, and the answer to both of my questions is 
"no". But I can't help but feel that we could be doing better than just 
expressing wishy washy feelings about our code quality. For example, user interface 
design is something that to a broad range of people looks for all the world like a 
field of study that oughtta be 100% subjective matter of taste. But this is shockingly 
and brutally not the case, and there are in fact many objective measures that can be 
applied to a user interface to determine its quality. A series of tests could be 
written to give a definitive and repeatable score to user interface quality. (See GOMS, 
for instance).

Now, okay. is Elegance simply "code quality" or is it something more? Is it 
something that can be measured? Or is it a matter of taste? Does our profession have 
room for taste? Maybe I'm asking the wrong questions altogether. Help me out here.

Bonus Round

If there is such a thing as elegance in code, and that concept is useful, do you think 
that justifies classifying the field of programming as an "Art" capital A, 
or merely a "craft". Or is it just an engineering field populated by a bunch 
of wishful thinking humans? Consider this question in the light of your thoughts about 
the elegance question.

Please note that there is a distinction between code which is considered 
"art" in itself, and code that was written merely in the service of creating 
an artful program. When I ask this question, I ask if the code itself justifies 
calling programming an art.

Bounty Note

I liked the answers to this question so much, I think I'd like to make a photographic 
essay book from it. Released as a free PDF, and published on some kind of on demand 
printing service of course, such as "zazz" or "tiggle" or 
"printley" or something . I'd like some more answers, please!

It's the intersection of simplicity and functionality.
Elegant code is code that does in a few crystal clear lines what you would think would 
take heaps of complex code to achieve.
My rough definition of "elegant code":

    Code which is written such that the number of lines/statements is minimized while 
    the readability and functionality is maximized.

Or, to put it another way:

    The ratios of readability to number of statements and functionality to number of 
    statements are both high.

I've specifically included readability here. There are plenty of "one-liners" 
that get a lot done, but if no one can tell what they are doing, they aren't elegant.
"Elegant" is a good word choice because it implies a sense of aesthetics. 
Deciding what is elegant and what isn't is an aesthetic judgement in code just as in 
other fields. It is subjective. What's elegant to one programmer might not be to 
another.

To expand the definition a little, you could say elegant code is code that gets 
something non-trivial done in a way that is simple. I don't think anyone disagrees on 
the non-trivial part, it's the simplicity that is the bugbear. Some people think 
simple means "as terse as possible", other people think it is "as easy 
to understand as possible", and many opt for some intersection of the two.
The code cannot be elegant as a whole without an elegant design. I think design 
elegance can be roughly measured using the MIT or "worse is better" approach 
measured by degrees of:

    * Simplicity
    * Correctness
    * Consistency
    * Completeness

A long time ago I thought about what attributes contribute to elegance. Here is the 
list that I came up with. Some of these apply to hardware as well, and there is some 
overlap, but anyway:

    * accurate, correct (operates exactly as instructed)
    * adaptable (easy to modify to suit other purposes)
    * attractive (aesthetically pleasing (but preferably not at the expense of functionality))
    * compact (small, lightweight, portable)
    * comprehensive (complete, thorough, solves for the general case)
    * consistent (predictable operation and user interface)
    * controllable (easy for operator to maintain complete control)
    * convenient (desirable to use)
    * customizable (tweakable)
    * durable (robust, rugged)
    * economical (inexpensive, cost-effective, low total cost of ownership)
    * effective (well-suited to intended purpose)
    * efficient (fast or otherwise resource-efficient)
    * environmentally-friendly (non-toxic; not wasteful)
    * ergonomic (comfortable; not harmful to operator)
    * extensible (easy to add new features)
    * failsafe (prevents undesired operation; discourages misuse; enforces proper 
      operating sequences; capable of failing gracefully and safely (but preferably not 
      silently))
    * functional (designed with function as a priority to form)
    * interoperable (compatible with other systems)
    * intuitive (user-friendly, unambiguous user interface)
    * maintainable (components are easy to access, repair, and replace)
    * modular (components are interchangeable, or system is interchangeable as a whole)
    * orthogonal (features operate independently of each other, or in any sequence, or 
all similar features are equally capable)
    * practical (economical; quickly and easily deployable)
    * precise (results are reproducible)
    * quiet (not contributing to noise pollution)
    * recyclable (components can be safely and easily recycled to reclaim materials)
    * reliable (stable, dependable, fault-tolerant)
    * reusable (components can be used for other purposes)
    * safe (non-toxic; alerts operator to potential problems)
    * scalable (suitable for use with larger-than-optimal workloads)
    * responsive (responds quickly to operator changes or changes in operating conditions)
    * secure or securable
    * self-correcting (automatically adjusts to improve precision)
    * self-tuning (automatically adjusts to improve efficiency based on current 
      operating conditions)
    * side-effect-free (does nothing beyond the stated function)
    * simple (straightforward, no superfluous features)
    * standards-compliant (conforms to established standards)
    * sustainable (can operate continuously)
    * upgradeable (easy to replace components to increase speed or capacity)
    * verifiable (testable, provable)
    * versatile (multipurpose, flexible)

ほかにもいろいろ意見が出てますので興味のあるむきはぜひ。 まあ大体、少ない行数で簡潔に書かれているとかいうことなんですかねえ。

■_ Rに苦戦中にて候

まあ「力技」ならできると思いますが、Rらしく片付けるにはどうすればいいのでしょう。

R version 2.8.0 (2008-10-20)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

(略)

> set.seed(2501)
> runif(1)
[1] 0.4495924
> runif(28)
 [1] 0.008427155 0.690209861 0.351806202 0.803484705 0.199760081 0.813214395 0.249922267 0.115819476 0.105845221
[10] 0.655866165 0.728389143 0.889194803 0.801840252 0.645406192 0.192559986 0.357885698 0.480223333 0.852629415
[19] 0.291657432 0.641162938 0.404079072 0.895537074 0.525941425 0.214164670 0.635425401 0.125924554 0.402252163
[28] 0.987311164
> c(runif(28))
 [1] 0.22084928 0.32975867 0.45890816 0.78704942 0.14933436 0.94654785 0.86139514 0.76345433 0.38214938 0.32084925
[11] 0.60319848 0.02469329 0.60367739 0.79539763 0.31969864 0.59009974 0.57974357 0.09518402 0.43318757 0.61901766
[21] 0.69752728 0.12420468 0.90689640 0.84989118 0.70208918 0.51336179 0.69364427 0.80056838
> f <- function(x) {x * 10}
> f(10)
[1] 100
> lapply(runif(28), f)
[[1]]
[1] 3.717819

[[2]]
[1] 4.191762

[[3]]
[1] 6.652099

[[4]]
[1] 9.761569

[[5]]
[1] 3.437065

[[6]]
[1] 2.389774

[[7]]
[1] 4.96059

[[8]]
[1] 0.5464849

[[9]]
[1] 2.583537

[[10]]
[1] 8.158069

[[11]]
[1] 2.71522

[[12]]
[1] 2.711017

[[13]]
[1] 6.6947

[[14]]
[1] 0.7944957

[[15]]
[1] 0.6928912

[[16]]
[1] 0.7455429

[[17]]
[1] 6.958066

[[18]]
[1] 4.932694

[[19]]
[1] 9.728446

[[20]]
[1] 4.196187

[[21]]
[1] 1.749680

[[22]]
[1] 3.7898

[[23]]
[1] 7.699372

[[24]]
[1] 8.057496

[[25]]
[1] 4.759207

[[26]]
[1] 0.881719

[[27]]
[1] 1.219329

[[28]]
[1] 4.918988

> sapply(runif(28), f)
 [1] 7.88493041 3.01683392 8.90609479 9.45750510 1.23384499 6.14264254 7.52977891 4.38006213 6.62979947 4.71119306
[11] 1.14897388 0.02750865 4.50157254 2.69674669 1.31512341 3.15011857 1.41817064 8.03758558 5.19288484 3.83047581
[21] 4.62866408 5.86589624 1.31563953 0.76473171 2.49459518 3.93853934 3.55282090 9.88078932
> fb <- function(x) {
+   if (x >= 0.6) return("A")
+   else if (x >= 0.3) return("O")
+   else if (x >= 0.1) return("B")
+   else return("AB")
+ }
> fb(0.5)
[1] "O"
> fb(0.8)
[1] "A"
> sapply(runif(28), fb)
 [1] "O"  "B"  "B"  "A"  "AB" "B"  "A"  "AB" "A"  "A"  "B"  "O"  "A"  "AB" "O"  "B"  "A"  "O"  "O"  "O"  "O"  "O" 
[23] "O"  "A"  "O"  "B"  "A"  "A" 
> table(sapply(runif(28), fb))

 A AB  B  O 
16  1  4  7 
> table(sapply(runif(28), fb))

 A AB  B  O 
11  3  8  6 
> table(sapply(runif(28), fb))

 A AB  B  O 
 9  3  8  8 
> table(sapply(runif(28), fb))

 A AB  B  O 
15  3  2  8 
> table(sapply(runif(28), function(x) {if (x >= 0.6) return("A")
+ else if (x >= 0.3) return("O")
+ else if (x >= 0.1) return("B")
+ else return("AB")
+ }
+ ))

 A AB  B  O 
11  4  6  7 

  

ナニがやりたかったというと、 昨日の東スポの一面にWBCの監督を務める原が血液型性格判断にご執心であり 今回のメンバー選定でも「活用」していて、現にB型が少ない(28名中3名)云々とかあったので、 そんなの無作為に選んだってありうる偏りの範囲だろうということで 適当に28名選出するというのを何回も繰り返して出力したいというのがひとつと (これはまあできてると思いますが)、その出力を

 A AB  B  O 
11  4  6  7 

だけではなくて、それぞれについて全体の何パーセントを占めているのかといったことも 同時に計算したかったわけです。

関数一覧見てもどの関数がナニをするやらさっぱりてな感じなので、 なんとも背中がむずがゆくなる状態です。

■_



推薦図書/必読書のためのスレッド 45 [bbs2chreader]
372 デフォルトの名無しさん [sage] Date:2009/02/23(月) 02:58:41  ID: Be:
    今更ながらAdvanced Windows第5版を買って読んでみた。
    勉強にもなるんだけど、それ以上にすごく面白かった。
    来月の食事が少し貧相になるけど、大満足です。 

373 デフォルトの名無しさん [sage] Date:2009/02/23(月) 07:27:20  ID: Be:
    >来月の食事が少し貧相になるけど
    ワロタw
    エンゲル係数下げてまでww

    いや、それでこそ技術者だ。 
413 デフォルトの名無しさん [sage] Date:2009/02/23(月) 22:40:26  ID: Be:
    それでもコードコンプリートはちと高い・・

414 デフォルトの名無しさん [sage] Date:2009/02/23(月) 22:42:25  ID: Be:
    >>409
    英語だが原書いっとけ。半額以下だ

    それにあの本は作法の事典みたいなもんだし
    一度読んでお蔵入りってことはなかろ 

420 デフォルトの名無しさん [sage] Date:2009/02/23(月) 23:18:24  ID: Be:
    おれは読みたい本全部買ってたら飢え死にするw

425 デフォルトの名無しさん [sage] Date:2009/02/23(月) 23:50:04  ID: Be:
    >>420
    読みたいのを全部買ってるわけじゃないけど、それでも
    読むのが追いつかなくて、積読になってる。
    2chなんてやってなかったら、もっと消化できるけど。
    あと、プログラミング系のやつって、繰り返し読んだり
    コード書いて遊んだりしないと消化した気分にならないしな。 

426 デフォルトの名無しさん [sage] Date:2009/02/23(月) 23:53:55  ID: Be:
    毎月2万ずつ本買ってみ。
    すぐに読むのが追いつかなくなるから、飢え死にの心配なんて無いよ。 
427 デフォルトの名無しさん [sage] Date:2009/02/23(月) 23:57:17  ID: Be:
    俺毎月4万くらいずつ本買ってるんだけど、読んでない本が本棚1本ある。
    500冊くらいか。どうすんだよ、これ。 

428 デフォルトの名無しさん [sage] Date:2009/02/23(月) 23:58:10  ID: Be:
    >>425
    俺も全く同じ状態だわ…
    2ちゃん閉鎖にならないかなー
    と2ちゃんに書き込む矛盾… 

429 デフォルトの名無しさん [sage] Date:2009/02/23(月) 23:58:25  ID: Be:
    裁断、スキャンしてpdfにしておくんだ 

430 デフォルトの名無しさん [sage] Date:2009/02/24(火) 00:01:04  ID: Be:
    俺は積ん読50冊くらいだけど、もうお手上げな感じ。 

431 デフォルトの名無しさん [sage] Date:2009/02/24(火) 00:08:17  ID: Be:
    とりあえず本棚を技術書でいっぱいにしてインテリジェンス感が味わえればそれでよいのだ 

432 デフォルトの名無しさん [sage] Date:2009/02/24(火) 00:12:08  ID: Be:
    技術者なら死ぬときは技術書の下 

433 デフォルトの名無しさん [sage] Date:2009/02/24(火) 00:23:02  ID: Be:
    地震が来たら死ねる自信がある 

432 は俺か?w

<
推薦図書/必読書のためのスレッド 45 [bbs2chreader]
455 デフォルトの名無しさん [sage] Date:2009/02/24(火) 17:09:11  ID: Be:
    生活ってさ、一週間が再帰してるだけだよな。
    たまに例外がキャッチされるけど。 

456 デフォルトの名無しさん [sage] Date:2009/02/24(火) 17:17:48  ID: Be:
    >>455
    スタックのオーバーフローだけは気をつけて。 

457 デフォルトの名無しさん [sage] Date:2009/02/24(火) 17:24:07  ID: Be:
    俺の財布スタックとTodoスタックがPopしようとすると
    stack is empty ってエラー吐きまくるんですけど 

458 デフォルトの名無しさん [sage] Date:2009/02/24(火) 17:26:34  ID: Be:
    財布はともかくToDoはpriority_queueにしておけ 

TODO リストが LIFO でいいのか?(^^;

/div> 1

■_ 本日の巡回から

2009年02月23日

■_

・なつたん駆動読書術
自分が読んだら貸すという約束をして、自分にプレッシャーをかける読書術w まあ厳密な締め切りがあるわけでもないんですけどね。

・あるイースターエッグにまつわる話
疲れた…○| ̄|_ → Bill Gates' Personal Easter Eggs in 8 Bit BASIC

■_ Guile がECMAscrpitを認識するでござる

ecmascript for guile -- wingolog

ecmascript for guile -- wingolog
ecmascript for guile
22 February 2009 4:45 PM (ecmascript | guile | compiler | goops | vm)

Ladies, gentlemen: behold, an ECMAScript compiler for Guile!

$ guile
scheme@(guile-user)> ,language ecmascript
Guile ECMAScript interpreter 3.0 on Guile 1.9.0
Copyright (C) 2001-2008 Free Software Foundation, Inc.

Enter `,help' for help.
ecmascript@(guile-user)> 42 + " good times!";
$1 = "42 good times!"
ecmascript@(guile-user)> [0,1,2,3,4,5].length * 7;
$2 = 42
ecmascript@(guile-user)> var zoink = {
                           qux: 12,
                           frobate: function (x) {
                              return random(x * 2.0) * this.qux;
                           }
                         };
ecmascript@(guile-user)> zoink.frobate("4.2")
$3 = 37.3717848761822

The REPL above parses ECMAScript expressions from the current input port, compiling 
them for Guile's virtual machine, then runs them - just like any other Guile program.

Above you can see some of the elements of ECMAScript in action. The compiler 
implements most of ECMAScript 3.0, and with another few days' effort should implement 
the whole thing. (It's easier to implement a specification than to document 
differences to what people expect.)

The "frobate" example also shows integration with Guile - the random 
function comes from current module, which is helpfully printed out in the prompt, 
(guile-user) above.

In addition, we can import other Guile modules as JavaScript, oops, I mean ECMAScript 
objects:

ecmascript@(guile-user)> require ('cairo');
$1 = #<<js-module-object> b7192810>
ecmascript@(guile-user)> $1['cairo-version']();
$2 = 10800

(略)

Guile が最初に発表された頃、様々な構文で書かれたマクロ(スクリプティング)言語を Schemeに変換して実行するというアイデアを使い物にならないだろうと思ったものですが、 十数年立つ間にまあ偉く変わったものだなあと(変換する先はSchemeではないですが)。

とはいえGuile のそれはソース→ソースの変換で、変換後のソースをさらにSchemeインタープリターで 実行というものでしたから、そのままでは今この時点でも無理があるかもしれませんが

■_ チェックしておくべき10の言語(その3)

H3RALD : 10 programming languages worth checking out
H3RALD

10 programming languages worth checking out
Sunday, December 21st 2008 @ 03:01 PM

    * Haskell
    * Erlang
    * Io
    * PLT Scheme
    * Clojure
    * Squeak
    * OCaml
    * Factor
    * Lua
    * Scala

Squeak

Squeak has become one of the most popular Smalltalk implementations available. It has 
been used in some very interesting projects:

Squeak は入手することのできる Smalltalkの実装として最もポピュラーなものの一つになりました。
すでにいくつかの非常に興味深いプロジェクトで使われつづけています。

    * EToys, a kids-oriented but powerful development environment built in Squeak, was 
      included as part of the educational sofware suite of the OLPC.
      子供向けであるもののSqueakを使って構築された強力な開発環境であるEToys は
      OLPCの educational sofware suite の一部として含まれています。

    * Seaside is a modern and very productive web framework running on Squeak.
      Seaside はSqeak 上で動作する modern and very productive なwebフレームワークです。
      
    * Croquet is a development solution to build complex, multi-user virtual worlds.
      Croquet は複雑なマルチユーザーの virtual worlds を構築するための
      development solution  です

If you ask Randal Schwartz, he'll explain you why Squeak and Smalltalk are at least 
worth a look. Personally, while I'm attracted by Smalltalk's unique approach to 
programming and its friendly syntax, I am still a bit overwhelmed by the way it works. 
Squeak, and Smalltalk in general, runs inside (literally) a virtual machine written in 
Squeak itself. This means that:

Randal Schwartz に訊ねてみれば、なぜ Squeak と Smalltalk が at least worth a look 
なのかを説明してくれるでしょう。
わたし個人としては、Smalltalk のプログラミングに対する unique なアプローチや
その親切な構文に attracted されていますが、
I am still a bit overwhelmed by the way it works. 
#overwhelm → 圧倒する、制圧する
Squeak (とSmalltalk 一般)はSqueak自身で記述された仮想機械の中で動作します。
つまりこういうことです。

    * You write your code inside Squeak
      Squeakのなかであなたのコードを書く
      
    * You debug, inspect and interact your code inside squeak
      Squeak の中であなたのコードをデバッグや inspect、interact します
      
    * You run your code inside Squeak
      Squeakの中であなたのコードを実行する
      
    * You can install Squeak on virtually any platform, including mobile phones, 
      fairly easily
      Squeak は事実上どんなプラットフォームにもインストールできます。
      

Everything lives inside Squeak. It's very weird to picture this without actually 
trying it, so I suggest you download it and give it a try: it will definitely be an 
unusual but intriguing experience.

すべてはSqueakの中で生きています。
実際に試さずににこれを説明することはとても大変なことなので
ダウンロードして試してみることをおススメします。


Smalltalk takes programming to a whole different level, which is simply unimaginable 
for other languages. In return, it asks you to fully embrace the Smalltalk way of 
doing things, according to which external text editors, external version control 
systems and other common tools familiar to traditional programmers simply loose their 
purpose.

Smalltalk はプログラミングをまったく違うレベルへと持っていきます。
それは他の言語には想像もつかないものです。
その見返りとして、あなたには何をするにもSmalltalk流を完全に受け入れることを要求されます。
外部のテキストエディターや
外部のバージョン管理システム。そして tradditional programmers に
なじみに深いその他の一般的なツールは simply loose their purpose.

To get you started…

    * Official Squeak Web Site
http://www.squeak.org/
    * Squeak by Example
http://squeakbyexample.org/
    * SqueakLand
http://www.squeakland.org/
    * Ruby's Roots: Smalltalk Comeback and Randal Schwartz on Smalltalk
http://www.infoq.com/articles/smalltalk-comeback-schwartz
    * FLOSS Weekly 29: Dan Ingalls
http://twit.tv/floss29

OCaml

Like Smalltalk, OCaml has been getting more attention recently than in the past. Sure, 
not everyone is planning to learn is these days, but after reading this article I admit 
I was eager to give it a proper try.

Smalltalkと同じように、OCamlも過去よりも最近になって注目を集めるようになってきたものです。
もちろん今日においてすべての人がこの言語を学ぼうと考えているわけではありませんが
after reading this article I admit I was eager to give it a proper try.

Despite being statically typed, OCaml offers some of the features which are common in 
dynamically typed languages like Ruby, such as duck typing, the possibility of 
creating Domain-Specific Languages and even extending the language syntax with custom 
operators and constructs.

OCamlは静的な型付けを行う言語ですが、Rubyのような動的言語において一般的な機能のいくつか、
たとえばダックタイピングようなものだとか、ドメイン特化言語 (Domain-Specific Languages) 
を作成する possibility、さらには演算子や構造のカスタマイズによる言語の構文の拡張と
いったものさえ提供しています。


Additionally, the OCaml Batteries Included project was created as an attempt to bundle 
a standard set of commonly-used library together with the language core. Even if this 
project is still in alpha stage, it definitely looks promising.

それに加えて、OCaml Batteries Included プロジェクトは言語のコアをと一緒に使われる 
commonly-used なライブラリの標準セットをバンドルするものとして作られました。
このプロジェクトが未だにα段階であったとしても、有望なものであることははっきりしています。

To get you started…

    * Official Caml Web Site
http://caml.inria.fr/
    * Objective Caml Tutorial
http://www.ocaml-tutorial.org/
    * A Concise Introduction to Objective Caml
http://www.csc.villanova.edu/~dmatusze/resources/ocaml/ocaml.html
    * The OCaml Alliance Network
http://wiki.cocan.org/
    * OCaml News
http://ocamlnews.blogspot.com/
    * OCaml Batteries Included
http://batteries.forge.ocamlcore.org/

Factor

Factor is to Forth what Clojure is to Common Lisp: a reincarnation of an ancient 
language in a more modern and practical form. In the specific case, although it 
borrows from Lisp and Self as well, Factor retains the main characteristics of its 
ancestor: it's stack-based, concatenative and has postfix notation. While this is 
enough to put some people off, if you digg deeper you'll discover that Factor offers 
all the most important features available in contemporary programming languages: 
garbage collection, dynamic typing, an object system, … they're just presented in a 
very different way:

Factor は、Common Lisp に対する Clojure のような立場の Forth に対するプログラミング言
語、つまり、古代の言語 (ancient language)がより近代的で実用的な姿になっての生まれ変わ
り (reincarnation) です。特定のものについてはLisp や Self などから受け継いだものもある
のですが、Factor は先祖の持つ主な性質を残しています。それは、スタックベースということ
であったり、concatenative であり、後置表記を用いているということです。このことは一部の
人をこの言語から遠ざけるには十分なものですが、digg deeper すれば現代的プログラミング言
語 (contemporary programming languages) において使うことのできる重要な機能のほとんどす
べて、たとえばガーベジコレクション、動的型付け、オブジェクトシステムといったものを
Factor が持っていることに気がつくでしょう。Factor では非常に異なるやりかたでそれらを提
供しています:


    “Learning Factor is tough. One reason for this is that Factor is very different from 
     other programming languages. Programmers today are used to imperative programming 
     languages where data is stored and passed around in named variables (or function calls, 
     which name their variables). Factor is the opposite of this. A lot of code tends to be 
     written in a functional style, and even more jarringly, variables are rare, only 
     referenced in a small fraction of words. Nobody intends to change any of this; it's a 
     feature, not a bug!”

     Factor を学ぶことは困難が伴います。その理由の一つは、Factor がその他のプログラミング言語とは
     非常に異なっているという点にあります。今日のプログラマーは名前のついた変数にデータを格納したり
     それ(や関数呼び出し)を使ってデータのやり取りを行う命令型プログラミング言語 (imperative
     programming languages)を使っていますが、Factor はその対極にあります。コードの多くは関数型の
     スタイルでかかれる傾向にあり、さらに jarringly (不快な、不調和な)なことには変数はほとんど
     使われずにワードの小さな断片においてのみ参照されます。これを変えようという人は皆無であり、
     it's a feature, not a bug!”


  Daniel Ehrenberg, Learning Factor

Like Haskell, Factor demands a completely different programming approach to what you 
may be used to, but once you get past that, it can be as useful as any other language, 
if not more. The Furnace web framework, which powers the Concatenative wiki, is 
entirely built in Factor and runs on top of a Factor web server.

Haskell同様、Factorはあなたがこれまで使ってきたであろうプログラミングとは
全く異なるアプローチを要求します。しかし一度 you get past that してしまえば
他の言語と同じように便利に使うことができるでしょう。
Furnace web フレームワークは powers the Concatenative wiki なもので
全体が Factorで構築され、Factor webサーバーの上で動作します。


To get you started…

    * Official Factor Web Site
http://factorcode.org/
    * Factor on the Concatenative Wiki
http://concatenative.org/wiki/view/Factor
    * Factor Documentation
http://docs.factorcode.org/
    * Learn Factor
http://learnfactor.org/
    * Planet Factor
http://planet.factorcode.org/

残り二つ。

■_ 本日の巡回から

2009年02月22日

■_

・はてなあたりに分室(笑)でもつくるか
日曜日の昼間に、部屋を片付けていたら買ったきり読んでいなかった。 圏論の基礎 が見つかりまして、その辺をついったでつぶやきましたところ、 Twitter / WAKATSUKI toshihiro: @finalfusion 黄色い本は,ほぼ 100 ... Twitter / Kazuhiro Inaba: なぜ圏論という言葉を聞きかじったオタは "Basic ... Twitter / Ikegami Daisuke: MacLane 本は数学の素養がないと読むのは簡単 ... Twitter / Ikegami Daisuke: Pierce の Basic Category f ... 等々、叱咤激励の数々をいただきました○| ̄|_ んで、 Twitter / Ikegami Daisuke: わからなかったら、「あきらめて」、ブログに書くといい ... というアドバイスもいただきましたので、 コメントをつけやすいところで書いた方が良いかなあと思った次第であります。 とはいうものの、どこでやればいいですかねえといまさらながら考え込んでしまったり。 メジャーなblogサイト(cocologとかlivedoorとかそのへん)は防火壁でブロックされて しまって会社からアクセスできない(いや、書く気はないんですが、読むこともできないのは ちと)のでした。はてなは(今のところ)大丈夫っぽいからはてなにしようかと考えてます。 まあ、本がくるまでに決めよう。

・本日のオススメ(その1)
某社では数年前から、「部分最適ではなく全体最適を考えて」等々の スローガン的なものが流れていましたが、ではその全体最適をどのように とらえてどのように行動すればよいのかということは[お察しください] だったりするわけですが、ふと書店で目に付いたのがこの本。 全体最適の問題解決入門―「木を見て森も見る」思考プロセスを身につけよう!
(なんでコンピュータ関係のフロアにあったのだろう? まあそのおかげで見つけられたのだけど)
内容はさておき(えーっ)、あとがきにあった次のエピソードが非常に心に残りました。

25年以上前のこと。QCサークル活動が全盛のころ。 トヨタの方々が、当時私の勤務していた会社を訪れ、QCサークルの発表をしてくれた。 (略) 主催してくださった中部品質協会の講師がおられる控え室まで押しかけて、 感動した気持ちを伝えた。 その時に1つ教えてもらったことがある。 「岸良クン、1つ覚えておくといいことがあるので、教えてあげる。 ああいうすばらしい発表はね、講評のやり方からも来るんだ。発表した後に、 何か問題点を指摘することは誰でもできるだろう。でも、発表した人はどう思うかい? 次にやる気になるかい? 我々は現場の人たちのやる気に支えられて仕事をしている。 だから、現場のやる気はとても大切だ。もしも、岸良クンが僕と同じ思いなら、 1つだけ実践してほしいことがある。それは 『いいところを2つ。欲を言えばのところを1つ』見つけることだ。 講評の際に常にそれを心がけてごらん。そうすれば、今日あなたが感動したチームメンバー以上に、 いつかあなたはなっているだろう」

自分も実践…できるといいなあ。

・本日のオススメ(その2)
root(ルート)から/(ルート)へのメッセージ―スーパーユーザーが見たひととコンピュータ
まあ今はひとり一台(以上)UNIXマシンの時代なので、複数人がひとつのマシンにぶら下がって という世界はなじみがない人も多いでしょうし、そういうマシンを管理する立場になる 人というのさらに少ないだろうと思います。 でも、インフラ(的なものも含めて)を動かし続けるということがどういうことか これを読んで得られるところもあるかもしれません。 自分はSLのエピソードが好きなんですよねー。 絶版になってしまう前にぜひ :)

あとでよむ。 三つ目はコメントがつくのを待つ。 Good Math, Bad Math : Gap Buffers, or, Don't Get Tied Up With Ropes? On Hacking - Richard Stallman Docs for the internals of CPython Implementation - Stack Overflow

■_ 本日の2chから


初心者のためのプログラミング言語ガイド Part13
742 デフォルトの名無しさん [] Date:2009/02/21(土) 14:07:32  ID: Be:
    IDEやソースファイル管理の使い勝手も含めて初心者向きなのは? 

743 デフォルトの名無しさん [sage] Date:2009/02/21(土) 14:34:55  ID: Be:
    扱いが簡単だから初心者向き、とも一概には言えないな
    一見無駄な努力をした方が初心者の教育には良いという意見もあるし 

744 デフォルトの名無しさん [sage] Date:2009/02/21(土) 14:40:24  ID: Be:
    IDE使わずに無駄な努力→定型処理の形式化→自動化
    というプログラミングの実践を含むからな
    ただしこれやり過ぎると、自己流になってIDEが与えられてその範囲だけでやれってなったときに苦労する可能性がある 

745 デフォルトの名無しさん [sage] Date:2009/02/21(土) 15:26:36  ID: Be:
    重要なのは投げ出さないこと 

746 デフォルトの名無しさん [sage] Date:2009/02/21(土) 15:27:40  ID: Be:
    >>742
    vc# 

747 デフォルトの名無しさん [sage] Date:2009/02/21(土) 19:51:53  ID: Be:
    >>745
    負けない事 投げ出さない事
    逃げ出さない事 信じ抜くこと
    駄目になりそうな時 それが一番大事 
【実験台】 Python 3.0 のお勉強 Part 1 【非互換】
18 デフォルトの名無しさん [sage] Date:2009/02/21(土) 02:11:06  ID: Be:
    3.0のdisutilsが2to3に対応してるので、
    出来る限りブランチ作らないで済むような配慮はあるみたい。
    勿論、それぞれのバージョンでのテストは必要になるけど。

    3.0の紹介にあるような変更は自動変換で殆ど2to3で自動変換される。
    でも、流石に全部とは言い切れない。細かいところは手作業による修正が必要。
    特に面倒だと思った所は文字列周り(repr, encoding)かな。
    大きな変更は不要なはずなので、テストさえしっかりと書いてれば(大前提)それほど大変な作業にはならない。

    python2.6 -3警告オプションでも、2to3でも補足されない変更は
    python-porting(ML)にも幾つか挙がってる。
    * file -> io.FileIO
    * doctest内等での文字列の表現。 'foo' -> b'foo'
    * os.path.walk
    * etc...

    後方互換を残し && 読みやすいコードを心掛けたいなら、多少工夫が必要なケースもあるけど、
    リファクタリングする丁度良い機会にもなる。


    # 3.0対応ライブラリ一覧 @pypi
    ttp://pypi.python.org/pypi?:action=browse&c=533&show=all
    他のプロジェクトでもtrackerやレポジトリのbranches覗いてみると、patchや3.0移植作業中のものが結構ある。

    # djangoの3.0移植の過程のまとめ
    ttp://wiki.python.org/moin/PortingDjangoTo3k 

20 デフォルトの名無しさん [sage] Date:2009/02/21(土) 12:13:49  ID: Be:
    >>18
    おお、こうしてまとめてみると移行プランがんばってるなー
    なにより3k用ブランチを作らないようにするアプローチがありがたい 

英語は、訳さずに読もう with 英英辞典
103 デフォルトの名無しさん [sage] Date:2009/02/19(木) 17:00:37  ID: Be:
    stackoverfolowに日本語で質問しまくろうぜ300件くらい

    会場
    http://stackoverflow.com/questions/ask

    スタックオーバーフローという、英語の質問サイトなんだけど、
    反応の速さがヤバイ。VIPを超えるかも。

    なんか書き込んで40秒で削除とか普通だし。
    時間帯にもよるが、ボランティアが300人ほど常駐しているようだ。

    そんで、このサイトに、英語でなくて、日本語で質問を
    書きまくって、やつらの反応をながめて楽しむスレ。

    なんか、日本語で書き込むと、頼みもしないのに
    翻訳エンジン使って、勝手に英語に翻訳したのを
    下のほうに張ってくれたりするし。

    しかも反応速度がヤバイ。尋常でない。

    ポストしてから2分後には張られてたりする。 

104 デフォルトの名無しさん [sage] Date:2009/02/19(木) 22:02:32  ID: Be:
    http://stackoverflow.com/questions/564756/should-i-just-give-up-on-programming

    また新たな課題文持ってきたぞ 

105 デフォルトの名無しさん [sage] Date:2009/02/20(金) 00:45:55  ID: Be:
    >>104
    You shouldn't give up. You really love programming. That's enough. 

106 デフォルトの名無しさん [] Date:2009/02/21(土) 13:36:06  ID: Be:
    >>103
    英語で書けって言われた。ポストして1分後に。 

107 106 [sage] Date:2009/02/21(土) 13:38:04  ID: Be:
    3分後に翻訳してくれたw
    http://stackoverflow.com/questions/572277/c 

113 デフォルトの名無しさん [sage] Date:2009/02/21(土) 23:22:09  ID: Be:
    >>107
    推測するに、どうもajax使って、
    「送信」ボタンが押されるのを待たずとも、
    1秒ごとに、入力フォームに入力された
    文章を、サーバーに送信しているのではないか?
    って思うんだが。
    そうでないと、あれだけのスピードで返事できないだろう?
    っていう。 

114 デフォルトの名無しさん [sage] Date:2009/02/22(日) 02:42:53  ID: Be:
    >>113
    回答するのは中の人じゃないんだろ。
    ユーザ同士なら答える側になれば
    そうなのか確認できるじゃまいか 

115 デフォルトの名無しさん [sage] Date:2009/02/22(日) 03:12:37  ID: Be:
    >>114
    ボランティア3000人確保したって
    どっかにかいてあったよ 

問題のスレ?みてみたけど面白い。 「お前さんには『メンター』が必要だな」とか。


くだすれFORTRAN(超初心者用)その4
62 デフォルトの名無しさん [sage] Date:2009/02/19(木) 23:33:41  ID: Be:
    IntelFortran6.0使ってたんだけど、
    11.0でコンパイルしなおしただけで計算時間が1/3になってワロタ
    別に最適化オプション何も使ってないデフォルトなんだけどな
    これでOpenMPで最適化したら一体どうなるんだ 

63 デフォルトの名無しさん [sage] Date:2009/02/20(金) 04:02:32  ID: Be:
    >>61
    黒カエラーはまだ直ってないなw
    誰もIntelに通報してないのか?

64 デフォルトの名無しさん [sage] Date:2009/02/20(金) 13:43:56  ID: Be:
    >>62
    7になった時にですごく良くなった気がする。
    あとはあまり変化は大きくない気がする。
    ・・・といって今使ってるのが9のままなので10,11でまた進歩があったのかな?
    SSE絡みでは順次良くなったそうだけど
    明示的にそれを使うことは少ないからなあ。 

65 デフォルトの名無しさん [sage] Date:2009/02/20(金) 14:23:19  ID: Be:
    DECのエンジニアが入ったのが7からだっけ?
    見違えるように良くなったって話だが 

66 デフォルトの名無しさん [sage] Date:2009/02/21(土) 00:20:22  ID: Be:
    昔のはVisualC++へのプラグインだったからなぁ。

67 デフォルトの名無しさん [sage] Date:2009/02/21(土) 10:32:37  ID: Be:
    つまらないことなんですけど
    みなさんはエラー系の出力はwrite(0,*)を使っていますか?
    それとも、標準出力もエラー出力も全部print *を使っていますか? 

68 デフォルトの名無しさん [sage] Date:2009/02/21(土) 19:42:57  ID: Be:
    >>67
    標準出力とエラー出力があるっていうのはUNIXの話だから、
    メインフレーム上がりでUNIXをおもちゃと馬鹿にしているおっさんたちは、
    そんなもの存在も知らず、相変わらず6番に出力していると思う。

今でもFortranの最適化というのはその筋の用途では群を抜いているんだろうか? Cにも restrict とかいろいろついたけど。 あと、入力が5番で出力が6番ってどんな理由でだっけ? 以前きいたことがあるはずなんだけど思い出せない。



スレッドを立てるまでもない質問雑談スレ36
205 仕様書無しさん [] Date:2009/02/16(月) 10:39:35  ID: Be:
    ttp://www.atmarkit.co.jp/news/200902/13/ntt.htmlcamp-administrator

    これってどうなのよ・・・・・
    どんだけ働かせたいっちゅうねん・・・・・・ 

206 仕様書無しさん [sage] Date:2009/02/16(月) 12:25:44  ID: Be:
    404 

208 仕様書無しさん [] Date:2009/02/16(月) 12:46:44  ID: Be:
    ミスってら・・orz
    ttp://www.atmarkit.co.jp/news/200902/13/ntt.html

209 仕様書無しさん [] Date:2009/02/16(月) 20:17:55  ID: Be:
    不景気ですな。 

210 仕様書無しさん [] Date:2009/02/16(月) 20:33:44  ID: Be:
    不景気ですよ。 

211 仕様書無しさん [sage] Date:2009/02/16(月) 20:46:40  ID: Be:
    自宅警備員対策のリモートオフィス 

これか。



NTTソフト、新型インフルエンザ対策のリモートオフィス - @IT

 NTTソフトウェアは新型インフルエンザなどの不測の事態が発生した場合でも、自宅から企業
の情報システムにアクセスし、安全に作業ができるようにする「新型インフルエンザ対策ソリュ
ーション」を2月13日に販売開始した。

 新ソリューションを利用することで、緊急時でも迅速にリモートオフィス環境を構築し、企業
が事業を継続できるという。提供するのはリモートオフィス環境の構築に関するコンサルティン
グと、リモートオフィス環境の構築支援。リモートオフィス構築では、NTTアイティが提供する
USBキーを使った画面転送型のシンクライアントサービス「マジックコネクト」を採用する。

 マジックコネクトは自宅のPCにUSBキーを挿すだけで、会社のネットワークにVPNでアクセスし、
社内のPCを利用できる。シンクライアントのサービスはASPで提供されるため、新たなハードウ
ェアの導入などは不要で、低コストでシステムを構築できるという。シンクライアントサービス
だけでなく、NTTソフトウェアが提供する「多地点電話会議システム」なども利用できる。


【鬱病】 壊れたプログラマー 16人目 【爆発】
859 仕様書無しさん [sage] Date:2009/02/21(土) 07:45:36  ID: Be:
    16歳の朝、母に連れられてお城に 

860 仕様書無しさん [sage] Date:2009/02/21(土) 08:07:01  ID: Be:
    そして伝説へ 

861 仕様書無しさん [sage] Date:2009/02/21(土) 09:02:08  ID: Be:
    あれが16じゃなくて30くらいなら母親の気持ちも理解できる 

862 仕様書無しさん [sage] Date:2009/02/21(土) 11:55:36  ID: Be:
    >>861
    お城じゃなくてハロワへ連れてけ 

863 仕様書無しさん [sage] Date:2009/02/21(土) 12:20:21  ID: Be:
    あの世界なら酒場に登録か?
    でも勇者に呼んでもらえないんだろうな 

864 仕様書無しさん [sage] Date:2009/02/21(土) 12:29:18  ID: Be:
    商人の町要員です 

865 仕様書無しさん [sage] Date:2009/02/21(土) 12:39:33  ID: Be:
    DQの酒場ってまさにハローワークだよな。
    大人になってようやく気が付いた。
    子供の頃は純粋だからな 

866 仕様書無しさん [sage] Date:2009/02/21(土) 12:45:36  ID: Be:
    そしてダーマの神殿が派遣会社w 

867 仕様書無しさん [] Date:2009/02/21(土) 13:15:48  ID: Be:
    ダーマ神殿に騙された!! 

868 仕様書無しさん [sage] Date:2009/02/21(土) 13:41:16  ID: Be:
    お前は黙ってろ 

869 仕様書無しさん [sage] Date:2009/02/21(土) 14:58:12  ID: Be:
    あの勇者人遣いが荒くって、
    しかもおれを「ハケンは使えない」ってバカにしやがって 

870 仕様書無しさん [sage] Date:2009/02/21(土) 15:05:02  ID: Be:
    そのくせ、あちこちで仲間にならないかっていいまわってるんだよ 

871 仕様書無しさん [sage] Date:2009/02/21(土) 16:55:40  ID: Be:
    商人希望したのになぜか街の建設やらされてた 

872 仕様書無しさん [sage] Date:2009/02/21(土) 18:46:09  ID: Be:
    魔法使いになったじいさんは一生出番ないんだろうなあ 

873 仕様書無しさん [sage] Date:2009/02/21(土) 20:46:49  ID: Be:
    そんでもって、35歳を過ぎると敵のバシルーラでもとの酒場に飛ばされるんだよね 

874 仕様書無しさん [sage] Date:2009/02/21(土) 21:26:16  ID: Be:
    そしてもう二度とお呼びがかからなくなるわけですね 

875 仕様書無しさん [sage] Date:2009/02/21(土) 21:29:25  ID: Be:
    あの勇者、おれがバシルーラで飛ばされる時、
    確かに「・・・リストーラ」って言いやがった。

    ちっくしょ~、ぜってぇ再合流してやるぜ 

876 仕様書無しさん [sage] Date:2009/02/21(土) 22:10:49  ID: Be:
    おまいら、DQでは、いつも「ガンガン戦え」って命令してたろ。
    HPが少なくても、毒に犯されてても、混乱していても・・・
    実際、される側になってそのつらさがよく分かるな。
    次のDQでは、「いのち大事に」と「逃げる」を使ってやろうぜ。 

877 仕様書無しさん [sage] Date:2009/02/21(土) 22:29:33  ID: Be:
    めいれいさせろ、だろ。 

うまいなこの流れw


組み込みプログラマー雑談スレッド その11
289 仕様書無しさん [sage] Date:2009/02/16(月) 21:11:30  ID: Be:
    デザインウエーブマガジン・・・・合掌。FPGA屋の拠り所が消えちゃったね。 

295 仕様書無しさん [sage] Date:2009/02/17(火) 08:51:11  ID: Be:
    >>289
    ディジタル・デザイン・テクノロジってのがどんな内容になるのかが気になるな 

296 仕様書無しさん [sage] Date:2009/02/17(火) 16:36:05  ID: Be:
    D.D.T って聞くと、殺虫剤のほうが思い浮かぶ 

297 仕様書無しさん [sage] Date:2009/02/17(火) 21:01:24  ID: Be:
    その殺虫剤は、デバッガの名前だった頃があるな。 

298 仕様書無しさん [sage] Date:2009/02/17(火) 21:37:04  ID: Be:
    >>297
    ダイナミックデバッギングツールだっけ?
    DEC の OS に乗っかって、その後 CPM で同名の奴ができたとか言う…

299 仕様書無しさん [sage] Date:2009/02/17(火) 21:56:57  ID: Be:
    ふるすぎ^^^^; 

300 た [sage] Date:2009/02/17(火) 22:05:38  ID: Be:
    DDTってCP/M86だっけ?
    SIDとかZSIDならCP/M80だよねー

    どちらにしてもスレ違いw 

301 仕様書無しさん [sage] Date:2009/02/17(火) 22:10:19  ID: Be:
    いいから腐海にお帰り、ここはおまえのくるところじゃないの。 

302 仕様書無しさん [sage] Date:2009/02/17(火) 22:25:25  ID: Be:
    場違いなコテがスレ違いとか言ってもなあ・・・ 

303 仕様書無しさん [sage] Date:2009/02/17(火) 23:53:33  ID: Be:
    この不景気に、あそこは嫌だこれは嫌だとわがまま放題言ってたら
    コボルの仕事に回された、短期だけど。
    コボルなんてわからんので、テスト要員。
    これは、なにかの罰ゲームだろうか 

304 仕様書無しさん [sage] Date:2009/02/18(水) 06:53:21  ID: Be:
    リストラ候補ですな 

305 仕様書無しさん [sage] Date:2009/02/18(水) 19:30:56  ID: Be:
    >>303
    つ「組み込みプログラマー」

    おまいは組み込まれプログラマー

306 仕様書無しさん [] Date:2009/02/19(木) 03:14:27  ID: Be:
    なぜハードウェア(基板)開発する人は組込み技術者って言われないのか 

307 仕様書無しさん [sage] Date:2009/02/19(木) 03:17:06  ID: Be:
    組み込んでないからな。
    いやまてよ。全ての基板は何かに組み込まれてるから、それは重複した表現だ! 

308 仕様書無しさん [] Date:2009/02/19(木) 03:46:03  ID: Be:
    基板組み込んでるし 

309 仕様書無しさん [] Date:2009/02/19(木) 03:49:34  ID: Be:
    機械技術者・研究者とか電子回路の技術者・研究者は正社員なのに、
    ソフト作る組込み技術者だけゴミみたいな扱いなのはなぜ? 

310 仕様書無しさん [] Date:2009/02/19(木) 03:56:08  ID: Be:
    ソフトなんてちょこちょこっと書けばいいだけじゃん
    間違っても変更ちょちょいのちょいだし 

311 仕様書無しさん [] Date:2009/02/19(木) 05:09:58  ID: Be:
    ついウッカリ間違って、Core2Duoを使うところを
    PICで回路組んじまったが今更基板変更できない
    から、ソフトをちょこちょこっと書き換えて対応しろよw 

312 仕様書無しさん [sage] Date:2009/02/19(木) 07:17:09  ID: Be:
    >>309 トランジスタの数が千個台のチップと、百万個、2億個のチップをまったく同じに考えているからです。 

315 仕様書無しさん [] Date:2009/02/20(金) 05:39:20  ID: Be:
    >>309 それは、ニセモノしか作れないからだ。 完璧なソフトを目指すのだ!
       あいまいな日常から脱出して、道を極めるのだ。

       おのが心に耳を澄ますと聞こえるだろ。
      「ニセモノはイヤだ~! もっと綺麗で完璧なモノを!」

       これこそ、プログラマーの性(さが)であり、命より大切なものだ! 

317 仕様書無しさん [sage] Date:2009/02/20(金) 13:43:34  ID: Be:
    そのソフト軽視の姿勢がiPhoneとSH-04Aの違い。

    21世紀の主戦場はソフトウェアなのに 

318 仕様書無しさん [] Date:2009/02/20(金) 14:48:29  ID: Be:
    製造業の技術者「ソフトなんか誰でもできるよ」 

どんだけの人が知ってるんだDDT。


この会社辞めようと思った腐れ上司の一言0x24 
84 仕様書無しさん [sage] Date:2009/02/21(土) 00:13:34  ID: Be:
    俺の会社は自分でマシン選んで予算申請しておk
    だけど上司より性能のいいマシンは買ってはいけないw

    アホだろw 

85 仕様書無しさん [sage] Date:2009/02/21(土) 02:36:10  ID: Be:
    上司がTK-80使ってたら、何にすればいいんだ? 

86 仕様書無しさん [sage] Date:2009/02/21(土) 03:38:26  ID: Be:
    そういうありえない仮定は立てても時間の無駄 

87 仕様書無しさん [sage] Date:2009/02/21(土) 04:22:45  ID: Be:
    >>86
    マ板の主旨のわかってない香具師おつ 

88 仕様書無しさん [sage] Date:2009/02/21(土) 05:11:20  ID: Be:
    >>87
    kwsk 

89 仕様書無しさん [sage] Date:2009/02/21(土) 08:32:00  ID: Be:
    ボケには突っ込めってことだろ。

    >>85
    そろばんか計算尺でも使っとけ。 

90 仕様書無しさん [sage] Date:2009/02/21(土) 08:58:55  ID: Be:
    マニュアルのない計算尺は持っているが、掛け算と割り算しか使い方が分からない
    メーカーに問い合わせたらマニュアルのコピーとかもらえないかなぁ 

91 仕様書無しさん [sage] Date:2009/02/21(土) 09:24:16  ID: Be:
    つ 計算尺推進委員会 

92 仕様書無しさん [sage] Date:2009/02/21(土) 09:42:28  ID: Be:
    >>91
    thx
    ちょっと勉強してくるわ 

93 仕様書無しさん [sage] Date:2009/02/21(土) 12:21:14  ID: Be:
    >>85
    ND80K買えば良いんじゃない? 

94 仕様書無しさん [sage] Date:2009/02/21(土) 20:29:37  ID: Be:
    >>91
    レンズマンみたいに、宇宙船の軌道計算するのに計算尺使うのかw 

95 仕様書無しさん [sage] Date:2009/02/21(土) 20:35:03  ID: Be:
    >>94
    また懐かしいものをw 

96 仕様書無しさん [sage] Date:2009/02/21(土) 20:45:26  ID: Be:
    アポロ11号に積まれてたCPUはファミコン並みの性能だったらしいな。 

97 仕様書無しさん [sage] Date:2009/02/21(土) 22:38:11  ID: Be:
    ファミコンで宇宙にいけるのか

98 仕様書無しさん [sage] Date:2009/02/21(土) 22:42:24  ID: Be:
    いやその理論はおかしい 

いや、使い方に説明が必要というのはわかる。けど 「マニュアル」があるのか? 計算尺に。

■_ 本日の巡回から

2009年02月21日

■_


OSC にも那須にも行かず。 OSCは行ったほうが良かったかなあ。 こういうのがあるのだったらw → http://www.oreilly.co.jp/editors/archives/2009/02/open-souce-conf.html

・新宿でカレー
あら、3/1になったのねん。

■_ R

あんまりまじめに入門してないので、プログラムを読み解くのに一苦労○| ̄|_

APL で書かれたライフゲームをネタに R に初挑戦 - sumim’s smalltalking-tos

arr1 = t(array(1:9, c(3,3)))
arr1 = Reduce("+", Map(function(x) arr1==x, c(2,3,4,5,8)))
arr2 = array(0, c(5,5))
arr2[2:4,2:4] <- arr1

life = function(ome){
  omes <- Map(function(dx) ome[,((1:ncol(ome)+dx-1) %% ncol(ome))+1], -1:1)
  omes2 <- Map(function(ome2)
    Map(function(dy) ome2[((1:nrow(ome2)+dy-1) %% nrow(ome2))+1,], -1:1), omes)
  sum <- Reduce("+", unlist(omes2, recursive=FALSE))
  Reduce("+", Map(function(i) Map(function(ea) sum==ea, 3:4)[[i]] & list(1, ome)[[i]], 1:2))
}

  
ライフゲーム - MEMO:はてな支店

life = function(m){
  rot = function(n,d) (1:n + d-1)%%n + 1
  shift = function(ds) m[rot(nrow(m),ds[1]),rot(ncol(m),ds[2])]

  ds = sapply(strsplit(outer(-1:1,-1:1,paste)," "),as.numeric)
  s = array(apply(apply(ds,2,shift),1,sum),dim(m))
  (s==3) + ((s==4) & m)
}

  
APL で書かれたライフゲームをネタに R に再挑戦 - sumim’s smalltalking-tos

life3 = function(m){
  rot = function(n,d) (1:n + d-1)%%n + 1
  shift2 = function(dx,dy) m[rot(nrow(m),dx),rot(ncol(m),dy)]
  s = apply(mapply(shift2,matrix(-1:1,3,3,T),matrix(-1:1,3,3)),1,sum)
  (m & (s==4)) + (s==3)
}

  

life4 = function(m){
  rot = function(n,d) (1:n + d-1)%%n + 1
  shift2 = function(dx,dy) m[rot(nrow(m),dx),rot(ncol(m),dy)]
  s = apply(mapply(shift2,matrix(-1:1,3,3,T),-1:1),1,sum)
  (m & (s==4)) + (s==3)
}

  

■_ The History of Python: Adding Support for User-defined Classes についたコメント

へんじつかないかなー



The History of Python: Adding Support for User-defined Classes
5 comments:

Ethan said...

    Hi, about introspection and "similar things looking similar", I'm 
    curious where the names came from for introspecting various things in Python: 
    func_name, func_doc, im_func, im_class, im_self, f_locals, f_builtins, etc.

    Ethan
    February 18, 2009 12:58 PM 

Guido van Rossum said...

    @Ethan: The names were the same as the internal names for the same things. The 
    naming style comes from an old C convention; UNIX system calls use this style too 
    (st_mtime, tm_sec, etc.).

    February 18, 2009 2:20 PM 

manuelg said...

    I like dictionaries/namespaces better than objects. For me, your accomplishment 
    with Python's implementation of user classes is on a par with Linus's insight to base 
    a DVCS on a "mere" filesystem that only tracks content based on 
    cryptographic hashes. A single idea, very simple but not _too_ simple, implies 
    everything else, to great success.

    Computer science is too important to leave in the hands of people who are not 
    implementors.

    February 18, 2009 2:37 PM 

Nicolas Grilly said...

    Thank you very much for this useful insight in the design of Python classes and 
    methods !

    This is probably the best answer I've ever read to the recurrent question 
    "why does Python need self?" ;-)

    And your explanations about why lack of variable declarations is essential to 
    Python philosophy is very useful too.

    February 19, 2009 3:01 PM 
Benjamin Higgins said...

    Guido, if you had to do it over again, would you require variable declarations 
    before first use (optionally w/ initializer)?

    February 19, 2009 4:03 PM 

最後の質問の答えはわたしも知りたい。 まあ UNIX の creat システムコールみたいなもんかもしんないけどさw (とするには影響がでかいか)

ローカル変数の「宣言」についてはRubyも似たような仕様ではあるのだけど、 まつもとさんも宣言の類は入れたくないってのはどこかで発言していたと思う。 ブロックパラメータのところで云々てのは議論があったと思うけど ({x, y; quux, foo|| } みたいに ; でパラメータとローカル変数を分けるとか)、

■_今日の巡回から


一つ前へ 2009年2月(中旬)
一つ後へ 2009年3月(上旬)

ホームへ


Copyright (C) 2009 KIMURA Koichi (木村浩一)
この文書の無断転載はご遠慮ください(リンクはご自由にどうぞ)。

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