ときどきの雑記帖 3mm方眼紙編

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

一つ前へ 2011年1月(中旬)
一つ後へ 2011年2月(上旬)

ホームへ

2011年01月31日

■_

・カイジ
TVアニメ『逆境無頼カイジ 破戒録篇』、2011年4月より日本テレビ系で放送 ONE OUTS も続きをやってくれんか喃。

■_ 先読み

今後、重要視されるプラグラミング言語はなんですか。教えてください できれば理由... - Yahoo!知恵袋

 
今後、重要視されるプラグラミング言語はなんですか。教えてください 
できれば理由もお願いします 
 

重要視されるかどうかはわかりませんけど.NET系言語は期待できますね。
理由は、私のように頭の固い人でも簡単にWindowsアプリケーションが作成できるところですね。w

 
CとC++は永遠に不滅。 
だといいなあ。 
色々な言語がCとC++を改良した言語だったりしますし。 
 
 
恐竜Cobolは細長く延々と生き残りそうなイメージがある。 
私が重要視(期待している)のはPerl6,とDです。 
Perl6は「20年、30年使い続けられる言語」を目標に開発されています(正式リリースには程遠いらしい)。 
Dは通称「ネイティブで動くJava」です。 
Javaのような文法・機能で、C並に高速なネイティブコードを吐きます(仮想機械は不要)。 
 
http://damako.net/perl6doc/ 
http://www.kmonos.net/alang/d/ 
 
 
やはりJAVAではないかと・・・ 

どうなんすかねー。

■_ そうきたか

(謎)

コメント: 人気のプログラム言語TOP 10 を解説せよ - スラッシュドット・ジャパン

Pythonのルーツが教育用言語(ABC言語)だから、お行儀が良いということでしょ?

■_ インターフェース

これ、呼び出し部分のインターフェースどうなってんだろう。 VB のあれににてるけど。

Zavolaj! « Just Rakudo It

    sub log1p(Num $x) returns Num is native("libm") { ... } 
    sub expm1(Num $x) returns Num is native("libm") { ... } 
    sub erf(Num $x) returns Num is native("libm") { ... } 
    sub erfc(Num $x) returns Num is native("libm") { ... } 
    sub tgamma(Num $x) returns Num is native("libm") { ... } 
    sub lgamma(Num $x) returns Num is native("libm") { ... } 
 
Okay, that was really, really easy to do. I am officially impressed by Zavolaj. 
 
I was thinking the next step is to make a module of this, which I think should be 
pretty easy. But I’m blocked on a name for it. Any suggestions? 

■_

もう一個。

Math::BigInt « Just Rakudo It

Math::BigInt 
By colomon 
 
I suspect everyone who plays around with numerical problems on Perl 6 has been as 
frustrated as I am not to have arbitrary precision integers in Rakudo. As a sort of 
first step toward getting them, I’ve thrown together the beginnings of a Math::BigInt 
module using the BIgDigit multiple-precision arithmetic library and Zavolaj. 
 
(Why BigDigit instead of GMP? Two simple reasons. First, building GMP failed on my 
main development machine (OS X 10.5). GMP’s suggestion for fixing the problem 
involved getting a new main development environment for the machine, which seemed like 
a major pain in the neck, and didn’t impress me with GMP’s portability. Second, GMP’
s main multiple-precision type is a C struct you store on the stack. That means using 
it with Zavolaj would have required creating wrappers for every GMP function I wanted 
to use. Yuck.) 
 
Without further ado, here’s a few examples: 

    > my @fib := Math::BigInt.new(1), Math::BigInt.new(1), *+* ... *; 
    > say @fib[200]; 
    453973694165307953197296969697410619233826 

    > my @powers-of-two := Math::BigInt.new(1), * * 2 ... *; 
    > say @powers-of-two[80]; 
    1208925819614629174706176 
 
(略)

BigInt リテラルみたいのがないと不便だよ。ということ?

■_

■_ んー

あれとかあれとか進まない…

2011年01月30日

■_

読んだ
価格戦争は暴走する
価格戦争は暴走する

人間はガジェットではない (ハヤカワ新書juice) コンピュータが仕事を奪う と読んできてさらにどうすりゃいいのよ感が強まったり。

■_ How to learn

正規表現道場 [chaika]
693 nobodyさん [] 2011/01/18(火) 19:32:41 ID:sm74ERjN Be:
    あの正規表現ですが、今までうまくつかえていないというか下手
    です。で、勉強しようと思うのですが、
    反復学習ソフト付き 正規表現書き方ドリル
    これいいですかね?
    オライリーとどっちがいいかなって思うんですけど。

694 nobodyさん [sage] 2011/01/18(火) 22:59:06 ID:??? Be:
    >>693
    Webでおk 

695 nobodyさん [sage] 2011/01/19(水) 10:36:15 ID:??? Be:
    >>693
    良いと思うよ。
    オライリーも良い本だけど、ひととおり基礎ができてからで良いと思う。 

698 nobodyさん [] 2011/01/19(水) 23:40:21 ID:zqG6AlFK Be:
    抽象的な質問で申し訳ないんですが、本の話が出たのでついでに伺いたいんですが。
    今まで表計算ソフトやデータベースソフトなど普通に習得し、
    更に興味が出てきたのでMySQLとPHPを使ってプログラミングしたり、
    apacheやPostFixなども何とか使えるようになり、何となく分かってきた感じがしてるのですが、
    正規表現に関しては、未だに「どうにか使っているけど、理解は出来ていない感じ」がします。
    とりあえずやってみて、だめで違う手を試してみたりして....
    まるで別種類な考え方が必要な気がします。

    なので質問なのですが、正規表現を理解するのに一番良い本とか、
    正規表現について「目から鱗が落ちた!!一皮むけた!!理解が深まった」
    って思えるような本とかあったら、紹介いただけないでしょうか??

    それとも忍耐強く、失敗しては考える繰り返しでなければ、習得できない物なのでしょうか??
    当方今年で三十路なので、頭が固くなってきてるのかもしれませんが、いまいち頭にしみ込みにくくなってるような気がしてます。
    もしよろしければお教え願います。 

699 nobodyさん [sage] 2011/01/20(木) 00:05:42 ID:??? Be:
    >>698
    何となく分かった気になっている時は何も分かってないからもっと簡単なのからやれ 

700 693 [] 2011/01/20(木) 01:01:52 ID:973KUxXQ Be:
    >>695
    ありがとうございます。
    基礎から勉強したいので、買います。

701 nobodyさん [sage] 2011/01/20(木) 13:16:18 ID:??? Be:
    正規表現のスレ (プログラム板や UNIX 板にもある) のログを見て、
    質問のお題を片っ端から解いていくと、結構良い練習になると思う。 

704 nobodyさん [sage] 2011/01/21(金) 18:26:53 ID:??? Be:
    >>698
    頭の良い人だとまた違うのかもしれないけど、
    我々のような凡人は繰り返しやって経験値を積むしかないかなあ、って気がする。
    で、何か読んで一つ山を越えたいなら、現状ではオライリー本の一択しか無いと思う。 


オライリーの、って詳説~だろうかクックブックだろうか。 いくらなんでも詳説~はハードル高いと思うけど(やろうとしていることから考えて)。

とにかく簡単なのから数をこなしていくのがいいと思うけどね。 というか正規表現であんまり難しいことをやろうとしない方がシアワセになれると思う。 ということでPEGとかその辺の入門書とかきぼー>○○さんとか××さんとか。

■_

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

283 仕様書無しさん [] 2011/01/29(土) 22:18:09 ID: Be: 
 画像処理系の仕事してるんだが自社製品の開発ばかりしてきて潰しが利かないことがいまさらながらわかった 
 みんなは転職できるスキルある? 
 
284 仕様書無しさん [sage] 2011/01/29(土) 22:31:41 ID: Be: 
 ない 
 
285 仕様書無しさん [sage] 2011/01/29(土) 22:37:11 ID: Be: 
 ↑ないw 
 
286 仕様書無しさん [] 2011/01/29(土) 22:43:01 ID: Be: 
 ないない 
 
288 仕様書無しさん [sage] 2011/01/30(日) 00:23:42 ID: Be: 
 まるでない。今の職をクビになったら路頭に迷うな 
 
290 仕様書無しさん [sage] 2011/01/30(日) 06:50:21 ID: Be: 
 組込み屋なら農業向けに 
 自動田んぼの水調整装置つくれよ 
 
293 仕様書無しさん [sage] 2011/01/30(日) 09:38:44 ID: Be: 
 >>290 
 買ってくれるなら作る。 
 
294 仕様書無しさん [sage] 2011/01/30(日) 09:42:26 ID: Be: 
 >>290 
 まずは仕様をだせ 
 

きびしいなあ。 自分もそうだけど。

■_ The Best Scripting Langauge?

また炎上しそうな話題を。

しかし元記事のこれはどう読むんだ? Scriptometer: measuring the ease of SOP (Script-Oriented Programming) of programming languages

The best scripting language? : programming
 
The best scripting language? (rigaux.org) 
 
Interesting, but very outdated. Bash has a debugger (but I have never used it), and 
SBCL is shebang-aware. The scoring based on the example programs is a bit unfair 
because many of the programs do not handle all possible file names correctly. 

 
 
This is an arbitrary scale that has no real significance. 
 
Haskell in my view is a much better language to do scripting in than D (although I'm 
sure others disagree, partly it's my lack of experience with D), but Haskell is 
heavily penalized because it lacks a debugger (which in all my years of Haskell 
development I have never missed). 

 
So, you lack experience with D, yet claim that Haskell is much better at scripting? 
I'm curious how you managed to reach that conclusion. 

 
I have used D extensively in a large project, but it was D1 not D2, and I haven't been 
using it recently. Hence my claim of inexperience. 

 
   This is an arbitrary scale that has no real significance. 
 
All scales are arbitrary: Celsius, Fahrenheit, Kelvin; kilometers versus miles. 
Significance or relevance is yet another, personal and contextual, scale. 
 
Ah, but this scale is arbitrary in that different things are given different scores 
for no reason, whereas Kelvin or Kilometers measure a single property and are 
consistent in their measure. 
 
Perhaps "inconsistent" is a better word. Whatever dude. You know what I mean. 
 
I was interesting in learning haskell, and I was interested in acquiring an 'official' 
scripting language, but after seeing how to edit a file in place to remove comments'#' 
 
c = unlines . map (takeWhile (/= '#')) . lines 
fop f n = do l <- fmap f (readFile n) 
 evaluate (length l) 
 writeFile n l 
main = getArgs >>= (fop c) . head 
 
I changed my mind 
 
 
actually, your script has a fair bit of unnecessary stuff. 
 
If you just want to pipe from stdin to stdout you can just do: 
 
main = interact $ unlines . map (takeWhile (/= '#')) . lines 
 
One liner isn't too bad in my view. 
 
Edit: equivalent to yours, but shorter (slightly): 
 
import System.Environment 

main = getArgs >>= mapM (\n -> readFile n >>= \f -> length f `seq` writeFile n (unlines . map (takeWhile (/= '#')) . lines $ f)) 
 
Note that the fact that you write to the same file you read interferes with lazy IO 
which introduces alot of pain into this. Most haskell solutions would write to a 
different filename to avoid this. 

Ewwwwwww. 
 
I don't like Haskell. 
 

Haskell とか D とかって「Scripting Langauge」なん?

■_

2011年01月29日

■_

これ面白そう → Software Bugs - Software Glitches

久しぶりに勉強会やらがなかった土曜日だった気がする。

今月の皇帝陛下
髪が短くなってる(まあ、1巻(アウステルリッツ)の時点では短髪でサングラスかけてたわけで)

■_ なんというか

よくあるパターンの質問ちゃあそうなんですが。

スクリプトの繰り返しの防止 | OKWave
 
下記のようなスクリプトがあります。 
これは、CSVファイルを1行表示し、編集可能にするスクリプトの1行表示部分です。 
これを全行表示するスクリプトに変更したいと考えています。 

    while ($cnt) { 
        foreach(@csv2){
             .............................. 
        } 
    }

とすると無限ループするようです。(サーバーが固まる) 
webで調べたのですが、$cnt = '1'or die "$!"としても抜けだせません。 
行が無くなったら作業を終了するとしたいのですが、どうすればいいでしょうか? 
初歩的な質問で恐縮なのですが、レンタルサーバーをこれ以上固まらせるわけ 
にもいかないため、ご教授頂ければと思います。 
 
 
    @csv2 = split(/\<>/,$csv[$param{'num'}]); 
    $cnt = '1'; 
    foreach(@csv2){ 
        &trString(\$_, "1",); 
        if($_ eq $csv2[-1]){ chomp($_); } 
        print "<tr>\n"; 
        print qq|<td><input type="text" name="$cnt" size="30" value="$_"></td>|; 
        print "</tr>\n"; 
        $cnt++; 
    } 

何をどう調べてこうなった。てな感じですが

みた感じ、質問文内のスクリプトは、
(1)配列@csvから1行抽出。
(2)抽出したものを分割したものをinputコントロールとして出力。
――としているので、全行出力するなら、@csvについてループさせる必要があります。

なので、$cntを操作しても、うまくいかないかと。
$cntは、1行を分割した個々の要素を数えるのに使っているので。

たとえば、質問文スクリプトをサブルーチン化して、@csvの各行に対してそれを呼び出す
ようにするとかいった方向でスクリプトを書き換えてみては。
  
ご回答大変ありがとうございます。
大変申し訳ございません。
当方、プログラマではなく、落ちてるCGIを弄る程度しか出来ず、基本的なことを学んでおりません。
サーバーが固まっても構いませんので、ざっくりとしたやり方をご教授いただけませんでしょうか?
  

うーん…

■_ 比較

こう、同じ(酷似)している部分と違う部分とを見ていくと、 それぞれの言語の設計思想というものが透けて見えて…くるか?

Java and C# Comparison

Java and C# Comparison 

This is a quick reference guide to highlight some key syntactical differences between 
Java and C#. 

This is not a complete overview of either language. Hope you find this useful! 

Also see VB.NET and C# Comparison. 
 
 
Program Structure 
Comments 
Data Types 
Constants 
Enumerations 
Operators Choices 
Loops 
Arrays 
Functions 
Strings Exception Handling 
Namespaces 
Classes / Interfaces 
Constructors / Destructors 
Objects Properties 
Structs 
Console I/O 
File I/O 


Java Program Structure C# 
package hello; 
 
public class HelloWorld { 
  public static void main(String[] args) { 
    String name = "Java"; 
 
    // See if an argument was passed from the command line 
    if (args.length == 1) 
        name = args[0]; 
 
    System.out.println("Hello, " + name + "!"); 
  }
}
using System; 
 
namespace Hello {
public class HelloWorld { 
    public static void Main(string[] args) { 
        string name = "C#"; 
 
        // See if an argument was passed from the command line 
        if (args.Length == 1) 
            name = args[0]; 
 
        Console.WriteLine("Hello, " + name + "!"); 
    } 
}
}
Primitive Types 

boolean 
byte 
char 
short, int, long 
float, double 

Value Types 

bool 
byte, sbyte 
char 
short, ushort, int, uint, long, ulong 
float, double, decimal 
structures, enumerations 
Reference Types 

Object (superclass of all other classes) 
String 
arrays, classes, interfaces 
Reference Types 
object (superclass of all other classes) 
string 
arrays, classes, interfaces, delegates 
Conversions 
 
// int to String 
int x = 123; 
String y = Integer.toString(x); // y is "123" 
 
// String to int 
y = "456"; 
x = Integer.parseInt(y); // x is 456 
 
// double to int 
double z = 3.5; 
x = (int) z; // x is 3 (truncates decimal) 
Convertions 
 
// int to string 
int x = 123; 
String y = x.ToString(); // y is "123" 
 
// string to int 
y = "456"; 
x = int.Parse(y); // or x = Convert.ToInt32(y); 
 
// double to int 
double z = 3.5; 
x = (int) z; // x is 3 (truncates decimal) 
Namespace 
package harding.compsci.graphics; 

 

import harding.compsci.graphics.Rectangle; // Import single class 
 
import harding.compsci.graphics.*; // Import all classes 
 
 
namespace Harding.Compsci.Graphics { 
 ... 
} 
 
or 
 
namespace Harding { 
 namespace Compsci { 
 namespace Graphics { 
 ... 
 } 
 } 
} 
Accessibility keywords 
public 
private 
protected 
static 
Accessibility keywords 
public 
private 
internal 
protected 
protected internal 
static 

private int mSize; 
 
public int getSize() { return mSize; } 
public void setSize(int value) { 
 if (value < 0) 
 mSize = 0; 
 else 
 mSize = value; 
} 
 
int s = shoe.getSize(); 
shoe.setSize(s+1); 
private int mSize; 
 
public int Size { 
 get { return mSize; } 
 set { 
 if (value < 0) 
 mSize = 0; 
 else 
 mSize = value; 
 } 
} 
 
shoe.Size++; 

// Character stream writing 
FileWriter writer = new FileWriter("c:\\myfile.txt"); 
writer.write("Out to file.\n"); 
writer.close(); 
 
// Character stream reading 
FileReader reader = new FileReader("c:\\myfile.txt"); 
BufferedReader br = new BufferedReader(reader); 
String line = br.readLine(); 
while (line != null) { 
 System.out.println(line); 
 line = br.readLine(); 
} 
reader.close(); 
 
// Binary stream writing 
FileOutputStream out = new FileOutputStream("c:\\myfile.dat"); 
out.write("Text data".getBytes()); 
out.write(123); 
out.close(); 
 
// Binary stream reading 
FileInputStream in = new FileInputStream("c:\\myfile.dat"); 
byte buff[] = new byte[9]; 
in.read(buff, 0, 9); // Read first 9 bytes into buff 
String s = new String(buff); 
int num = in.read(); // Next is 123 
in.close(); 
 
 
using System.IO; 
 
// Character stream writing 
StreamWriter writer = File.CreateText("c:\\myfile.txt"); 
writer.WriteLine("Out to file."); 
writer.Close(); 
 
// Character stream reading 
StreamReader reader = File.OpenText("c:\\myfile.txt"); 
string line = reader.ReadLine(); 
while (line != null) { 
 Console.WriteLine(line); 
 line = reader.ReadLine(); 
} 
reader.Close(); 
 
 
// Binary stream writing 
BinaryWriter out = new BinaryWriter(File.OpenWrite("c:\\myfile.dat")); 
out.Write("Text data"); 
out.Write(123); 
out.Close(); 
 
// Binary stream reading 
BinaryReader in = new BinaryReader(File.OpenRead("c:\\myfile.dat")); 
string s = in.ReadString(); 
int num = in.ReadInt32(); 
in.Close(); 
 

Creative Commons License 
This work is licensed under a Creative Commons License. 
 

適当に省略してますのでご注意を。 Java で無符号の整数型がないのはなんでだっけか。

■_ 紀伊國屋書店

推薦図書/必読書のためのスレッド 60

820 デフォルトの名無しさん [sage] 2011/01/29(土) 16:56:58 ID: Be: 
 新宿の紀伊国屋の洋書コーナーの品揃えはかなり良いね 
 5階の日本語の方はほぼ全種Oreilly揃ってるし 
 
 ところで黒字に黄色い文字のシリーズ(洋書)ってなんて言うんだ? 
 
821 デフォルトの名無しさん [sage] 2011/01/29(土) 17:18:11 ID: Be: 
 黒字に黄色っていったらApressの本ぐらいしか浮かばないが 
 
822 デフォルトの名無しさん [sage] 2011/01/29(土) 17:32:13 ID: Be: 
 APRESSは入門向けが多いイメージ 
 
823 デフォルトの名無しさん [sage] 2011/01/29(土) 17:40:24 ID: Be: 
 Apress Oreilly manning 世界シェアってどうなってんの? 
 
824 デフォルトの名無しさん [sage] 2011/01/29(土) 17:45:03 ID: Be: 
 17.8% 
 
825 デフォルトの名無しさん [] 2011/01/29(土) 18:26:50 ID: Be: 
 Proなんたらってシリーズかしら? 
 
826 デフォルトの名無しさん [sage] 2011/01/29(土) 18:28:05 ID: Be: 
 そうですね 
 
827 677 [sage] 2011/01/29(土) 20:32:53 ID: Be: 
 >>683 
 >UMLモデリング入門 本質をとらえるシステム思考とモデリング心理学 
 読了。面白かったです。 
 
 モデル化したものをコードに落とす作業を解説した本ってありますかね。 
 
828 デフォルトの名無しさん [sage] 2011/01/29(土) 21:23:44 ID: Be: 
 Doug Rosenberg ユースケース駆動開発実践ガイド (OOP Foundations) 
 たとえば、こんなの。 
 
829 デフォルトの名無しさん [sage] 2011/01/29(土) 21:25:58 ID: Be: 
 >>827 
 Javaで良いんかいな? 
 
 メジャーどころでPofEAA 
 http://www.amazon.co.jp/dp/4798105538 
 とかDDD(今年日本語版出るらしい) 
 http://www.amazon.co.jp/dp/0321125215 
 かな。 
 
 もっと実装寄りがお好みならHibernateインアクション 
 http://www.amazon.co.jp/dp/4797330805 
 …なんだけどこれも絶版。 
 英語版だと続編出てるけどモデリングの部分は変わってない 
 (JPA対応、つまりHibernate実装依存の部分が加筆されてるだけ)。 
 

「新宿の紀伊國屋書店」って二箇所あるんだが…w あなたの街の紀伊國屋書店-新宿本店- あなたの街の紀伊國屋書店-新宿南店- 5階の日本語の方~ということから、 たぶん新宿南店のことだろうけど(本店の洋書の具合はどうだったかなあ)。

DDD いくらになるんだろう…(^^; 8000円台くらいだろうか。

■_ Monad と

関数型プログラミング言語Haskell Part13

690 デフォルトの名無しさん [sage] 2011/01/29(土) 01:34:01 ID: Be: 
 だれかモナドとArrowを分かりやすく説明してくれ・・・ 
 
691 デフォルトの名無しさん [sage] 2011/01/29(土) 02:37:06 ID: Be: 
 >>690 
 世界で一番か二番くらいにやさしい「モナド入門」 
 http://d.hatena.ne.jp/m-hiyama/20060419/1145432492 
 Arrowの紹介 for 2ch 
 http://www.aya.or.jp/~takuo/arrow_for_2ch/arrow_for_2ch.pdf 
 
692 デフォルトの名無しさん [sage] 2011/01/29(土) 04:46:15 ID: Be: 
 >>690 
 Monadは、説明を聞くよりもStateモナドとListモナドを自分で再実装していじくりまわすのがお勧め。 
 
693 デフォルトの名無しさん [sage] 2011/01/29(土) 05:34:40 ID: Be: 
 MonadよりComonadの解説が聞きたい 
 
694 デフォルトの名無しさん [sage] 2011/01/29(土) 08:35:46 ID: Be: 
 余モナドって使えるもの? 
 
695 デフォルトの名無しさん [sage] 2011/01/29(土) 12:59:41 ID: Be: 
 Arrowは.NETのRx的な感じなのかなー。数学的な位置づけとかは良く解らんが、使い方はわかった。 
 誰かがRxはモナドなのかとか言ってたがそれにはうまく答えられんがw 
 
696 デフォルトの名無しさん [sage] 2011/01/29(土) 13:00:33 ID: Be: 
 >>690 
 アローの自分の理解 
  受け取り:関数 
  返すもの:(関数の引数の型)と(関数の戻り値の型)を入れた箱 
 
 アロー同士をくっつけて、関数を色んなやり方で合成出来る 
 関数A:文字列(テーブル名) -> 数値(主キー)を 
 関数B:数値(主キー) -> 文字列(名前) 
 関数C:数値(主キー) -> 性別(名前) 
 この3つに対応するアローを作って適切な順序で合成すると、 
 テーブル名を入力して、(文字列,性別)の組を返す関数が作れる 
 
697 デフォルトの名無しさん [sage] 2011/01/29(土) 13:39:43 ID: Be: 
 >>696 
 わざわざアローを使う意義がわからんなぁ 
 それなら、普通に関数の合成でよくない? 
 
 アローによって抽象化された概念が、 
 関数の合成「以外」にも応用できないと、 
 抽象化の意味があまりないような気がする 
 
 アローによって抽象化された概念とやらが 
 一体何なのか未だによく分らんが 
 
698 デフォルトの名無しさん [sage] 2011/01/29(土) 14:17:35 ID: Be: 
 >>697 
 そうかもしれない 
 
700 デフォルトの名無しさん [sage] 2011/01/29(土) 18:11:02 ID: Be: 
 >>690 
 3分で解るHaskellのArrowの基本メモ 
 http://d.hatena.ne.jp/r-west/20070529 
 MonadとArrowの関係。 
 http://d.hatena.ne.jp/r-west/20070531 
 do記法でArrowを使いこなす基本メモ 
 http://d.hatena.ne.jp/r-west/20070604 
 ArrowによるHaskellプログラミングの基礎。…パイプ感覚で順次/分岐/繰返し 
 http://d.hatena.ne.jp/r-west/20070720 
 
 >>697 
 副作用がある特別な値を抽象化したのがモナドで、 
 副作用がある特別な関数を抽象化したのがアローですよね。 
 普通の関数合成はアロー合成の代わりにならないのでは? 
 
701 デフォルトの名無しさん [sage] 2011/01/29(土) 18:44:16 ID: Be: 
 Arrowって魅力的な実例が少ないんだよな 
 正確に言うと、MonadにはならないがArrowになる実例 
 パーサもFRPもXML処理もMonadになることが多そうだし 
 
702 デフォルトの名無しさん [sage] 2011/01/29(土) 19:23:15 ID: Be: 
 >>700 
 > 副作用がある特別な関数を抽象化したのがアローですよね 
 
 そうなの? 
 
 「計算」という概念を抽象化して圏論の視点で構築したのがアローじゃないの? 
 モナドも「計算」という視点で捉え直せば Kleisli というアローで一般化できるのだと 
 
 アロー自体に副作用の概念は特にないと思ってたのだが 
 
703 700 [sage] 2011/01/29(土) 20:29:53 ID: Be: 
 >>702 
 正しくは「抽象化した」でなく「抽象化できる」ですね。 
 確かにアロー自体には副作用の概念はなく 
 副作用があろうがなかろうがアローにできます。 
 
 実際にアローを使うのは普通の関数では書けない時だから 
 その時はアロー合成を関数合成に置き換えられないという話です。 
 
704 デフォルトの名無しさん [sage] 2011/01/29(土) 20:43:46 ID: Be: 
 副作用の話はとりあえず置いておいて 
 
 確認なんだけど、結局同じ引数に適用したら同じ値に還元されるという意味において、 
 モナドは 100% アローで表現可能だし、アローは 100% モナドで表現可能だよな? 
 
 もしかして違うか? 
 
 違ってたら完全に私の認識が間違ってるっぽいから、 
 もう一度ちゃんと勉強し直したい 

705 デフォルトの名無しさん [sage] 2011/01/30(日) 01:12:31 ID: Be:
    >>704
    > アローは 100% モナドで表現可能だよな?

    違う。少なくとも、HaskellのControl.ArrowとContorol.Monadはそうではないし、
    数学的にも、よく分からんが、たぶんデカルト圏かならずしもモナドならず、ということだと思う。

    Arrowインスタンスにappメソッドが定義されていればそれはモナドと等価であるけど、定義されていない、定義できないのであればモナドではない。

    appメソッドは次のように宣言されている:
    class Arrow a => ArrowApply a whereSource
    app :: a (a b c, b) c

    Arrow記法で書くと
    x <- aArrow -< aValue
    と
    x <- app -< (aArrow, aValue)
    が同じ意味であるようなappを定義できるか、ということになる。 

706 705 [sage] 2011/01/30(日) 01:25:17 ID: Be:
    オレがこの間まで試していたものが、実際にこのappを定義できないArrowだった。

    data MyArrow a b = MyArrow {
    runMyArrow :: a -> (b, MyArrow a b)
    }
    stepper :: b -> (b -> a -> b) -> MyArrow a b
    stepper init f = MyArrow $ \a -> (f init a, stepper (f init a) f)

    このMyArrow型はメモリのある電子回路のようなものをイメージしており、
    例えば、
    st = stepper 0 (+)
    (x, st') = runMyArrow st 10
    -- x = 10
    (y, st'') = runMyArrow st' 5
    -- y = 15
    (z, st''') = runMyArrow st'' (-20)
    -- z = -5
    というように使う。

    これをArrow、ArrowChoice、ArrowLoopのインスタンスにすることはできたのだが、
    ArrowApplyのインスタンスにすることは出来なかった。
    考えみれば、

    y <- stepper 0 (+) -< x
    と
    st <- arr (const $ stepper 0 (+)) -< ()
    y <- app -< (st, x)

    が同じ意味になるように定義することはできない。少なくともオレがモデル化しようとしていた回路の世界では。
    上の例だと、その回路には最初からカウントアップする回路部品が含まれており、
    回路全体が繰り返し計算されることによってカウントアップされていく。

    しかし、下の例だと、回路全体を計算するたびに新たにカウントアップ部品が生成されてしまうので、意味がない。
    手前味噌かつ簡潔すぎて分かりにくいと思うが、まぁ、モナドに出来ない具体例は意外と簡単に見つかるよ、という話。 

707 デフォルトの名無しさん [sage] 2011/01/30(日) 01:43:04 ID: Be:
    デカルト圏とカルテシアン閉圏って同じなの? 

708 705 [sage] 2011/01/30(日) 02:01:13 ID: Be:
    ごめん。
    > たぶんデカルト圏かならずしもモナドならず、ということだと思う。

    というのは、分かっていないのにディレッタンティズムに駆られて余計なことを書いた。
    これは取り消す。 

709 デフォルトの名無しさん [sage] 2011/01/30(日) 02:24:53 ID: Be:
    あかん、本質的に Arrow とは何かを学び直さないと

    論文漁ってくる 

ううむ。よくわからん用語が飛び交っている(聞き覚えはある)。

■_

2011年01月28日

■_

・キンコーズ
MOからデータを引っ張り出すために行ってきた。 やっぱあれかなあ。印刷関係で割りと使われたらしいからそれでドライブの用意があるのかなあ >キンコーズ

・ダブルフェイス
新刊買った。いいところで次の巻に引っ張るなあ
ダブル・フェイス 23 (ビッグコミックス)
ダブル・フェイス 23 (ビッグコミックス)

■_ Mathematica

なんで日本語版には Home Edition ないの~ というか英語版でいいんだけど。

Mathematica - Wikipedia, the free encyclopedia
Licensing

Mathematica is proprietary software restricted by both trade secret and copyright law.[45]

A regular single-user license for Mathematica used in a commercial environment costs 
$2495. It includes four additional kernels for parallel computations and one year of 
service that includes updates, technical support, a home use license, a webMathematica 
Amateur license[46], a Wolfram Workbench license and three Mathematica Player Pro 
licenses. Discounts are available for government, charity, educational, pre-college, 
school, student, home use[47] and retiree use and depend on geographical region. 
Student licenses cost $140. A general "home use" license ("Mathematica 
Home Edition") is also available to the public and is priced at $295. Educational 
site licenses allow use by students at home. A license manager similar to FLEXnet is 
available to provide sharing of licenses within a group.

…通常のも 2495 ドルが40万オーバーってのも一言二言言いたくなるような値段だなあ。

んでまあ、たとえばフリーソフトウェアの数式処理ソフトウェアやらと比べてどうなのよ ってのはよく知らんのですけどね。 実際そういうものでも自分の用途には十分な気はするんですが、 高い腕時計とかカメラが欲しいってなかんじで一度は試してみたいと(笑) とはいえ気軽にぽんと出せる金額じゃねえよなあ ○| ̄|_

…もう一回学生になるか(笑)

■_ st.c

Ruby のソース見てて気になった部分があるのだけど、 こういうのもチケット起こして質問したほうがいいのかしらん。

[ruby] / trunk / st.c 	Repository: ruby
ViewVC logotype
View of /trunk/st.c

Parent Directory Parent Directory | Revision Log Revision Log
Revision 30679 - (download) (annotate)
Thu Jan 27 14:30:00 2011 UTC (19 hours, 14 minutes ago) by nobu
File size: 31633 byte(s)

(略)

int
st_foreach(st_table *table, int (*func)(ANYARGS), st_data_t arg)
{
    st_table_entry *ptr, **last, *tmp;
    enum st_retval retval;
    st_index_t i;

    if (table->entries_packed) {
        for (i = 0; i < table->num_entries; i++) {
            st_index_t j;
            st_data_t key, val;
            key = (st_data_t)table->bins[i*2];
            val = (st_data_t)table->bins[i*2+1];
            retval = (*func)(key, val, arg);
	    if (!table->entries_packed) goto unpacked;
            switch (retval) {
	      case ST_CHECK:	/* check if hash is modified during iteration */
                for (j = 0; j < table->num_entries; j++) {
                    if ((st_data_t)table->bins[j*2] == key)
                        break;
                }
                if (j == table->num_entries) {
                    /* call func with error notice */
                    retval = (*func)(0, 0, arg, 1);
                    return 1;
                }
		/* fall through */
	      case ST_CONTINUE:
		break;
	      case ST_STOP:
		return 0;
	      case ST_DELETE:
                table->num_entries--;
                memmove(&table->bins[i*2], &table->bins[(i+1)*2],
                        sizeof(struct st_table_entry*) * 2*(table->num_entries-i));
                i--;
                break;
            }
        }
        return 0;
      unpacked:
	ptr = table->head;
	while (i-- > 0) {
	    if (!(ptr = ptr->fore)) return 0;
	}
    }
    else {
	ptr = table->head;
    }

    if (ptr != 0) {
	do {
	    i = ptr->hash % table->num_bins;
	    retval = (*func)(ptr->key, ptr->record, arg);
	    switch (retval) {
	      case ST_CHECK:	/* check if hash is modified during iteration */
		for (tmp = table->bins[i]; tmp != ptr; tmp = tmp->next) {
		    if (!tmp) {
			/* call func with error notice */
			retval = (*func)(0, 0, arg, 1);
			return 1;
		    }
		}
		/* fall through */
	      case ST_CONTINUE:
		ptr = ptr->fore;
		break;
	      case ST_STOP:
		return 0;
	      case ST_DELETE:
		last = &table->bins[ptr->hash % table->num_bins];
		for (; (tmp = *last) != 0; last = &tmp->next) {
		    if (ptr == tmp) {
			tmp = ptr->fore;
			*last = ptr->next;
			REMOVE_ENTRY(table, ptr);
			free(ptr);
			if (ptr == tmp) return 0;
			ptr = tmp;
			break;
		    }
		}
	    }
	} while (ptr && table->head);
    }
    return 0;
}

(略)

この do ~ while の条件判定にある table->head って見る必要あるんでしょうか? ループ中で書き換えられることはないですよね? ptr が !0 で、table->head が 0 という状況にはならんと思うのですが、んー。

■_ Excel A1 R1C1

VBA でごにょごにょすることが相変わらず続いてたりするんですが。

VBA である範囲のセル群の値をまとめて読んできて何か処理をして、 それを書き戻すなんてのをやるときにセルのアドレス指定が A1 形式だと 困ることがありますね。といって R1C1 形式にすると影響がでかい。

あと、配列のある一部分だけ書き戻すなんてのがやり辛いのがちと不満。 配列丸ごとだと、.range(ほげほげ) = V と一行で終わるんですが、 一部だけだと、セルをひとつひとつ書き戻さないといけないという…

■_

■_

合名会社とか合資会社と、合弁会社ってちと分類が違うんじゃないのかな。と。

2011年01月27日

■_

あなたはどこに? → Kazimir Majorinc's Lisp Notes.: Find Your Way Through Lisp Labyrinth.

モーニングに月イチ連載されている「グラゼニ」がなかなか良い。

■_

【コラム】攻略! ツール・ド・プログラミング (44) 高速な文字列検索を実現するJavaライブラリ「StringSearch」 | エンタープライズ | マイコミジャーナル

各種文字列検索アルゴリズムを実装したStringSearch 
 
Johann Burkard氏が公開しているStringSearchは、高速な文字列検索アルゴリズムを実装した
Java用ライブラリである。BNDM法や、BMH法とその派生、Bit-parallel手法といった複数のアル
ゴリズムをサポートしている点が特徴。いずれのアルゴリズムを利用する場合でも基本的な使い
方は共通しているため、用途によって簡単に使い分けることができる。 
 
(さくっと略)

ShiftOrクラス 
 
 * Bit-parallel手法の一種であるShift-Orアルゴリズムの実装 
 * String.indexOf()メソッドよりも遅い 
 * 文字クラスを使う場合(後述)に有用(それ以外の場合は他のクラスを使った方が速い) 
 * searchChars()メソッドはJVM上では非常に遅いので、できる限りsearchBytes()メソッドを使うべき 
 * 31文字以下の文字列のみサポート 
 

結構あるもんだな(削っちゃったけどw)。 んで、ShiftOr ってむかーしCマガジンで見た vivi (Windows用のエディターのあれ)の 検索についての解説記事にあったのと同じようなもんだろか。 って、vivi のあれは正規表現検索だったか。

■_ magic increment

2011/Jan/27(木) - MetaNest あねっくす
これは Perl 由来か? 

$ php -r '$foo = "z"; $foo++; echo $foo; echo "\n";' 
aa 
$ ruby -e 'puts "z".succ' 
aa

実は Ruby も。

>ruby -e "puts 'z'.succ"
aa

Perl が元祖だったと思うけど、magic increment で検索しても今ひとつな結果だなあ。 Perl の FAQ がひっかかったりはするのだけど。

■_

Ksplice » 8 gdb tricks you should know - System administration and software blog

8 gdb tricks you should know 
 
Despite its age, gdb remains an amazingly versatile and flexible tool, and mastering 
it can save you huge amounts of time when trying to debug problems in your code. In 
this post, I'll share 10 tips and tricks for using GDB to debug most efficiently. 
 
I'll be using the Linux kernel for examples throughout this post, not because these 
examples are necessarily realistic, but because it's a large C codebase that I know 
and that anyone can download and take a look at. Don't worry if you aren't familiar 
with Linux's source in particular -- the details of the examples won't matter too much. 
 
1. break WHERE if COND 
 
If you've ever used gdb, you almost certainly know about the "breakpoint" 
command, which lets you break at some specified point in the debugged program. 
 
But did you know that you can set conditional breakpoints? If you add if CONDITION to 
a breakpoint command, you can include an expression to be evaluated whenever the 
program reaches that point, and the program will only be stopped if the condition is 
fulfilled. Suppose I was debugging the Linux kernel and wanted to stop whenever init 
got scheduled. I could do: 
 
  (gdb) break context_switch if next == init_task 
 
Note that the condition is evaluated by gdb, not by the debugged program, so you 
still pay the cost of the target stopping and switching to gdb every time the 
breakpoint is hit. As such, they still slow the target down in relation to to how 
often the target location is hit, not how often the condition is met.

(略)

8. The x command 
 
Most people who've used gdb know about the print or p command, because of its obvious 
name, but I've been surprised how many don't know about the power of the x command. 
 
x (for "examine") is used to output regions of memory in various formats. It 
takes two arguments in a slightly unusual syntax: 
 
x/FMT ADDRESS 
 
ADDRESS, unsurprisingly, is the address to examine; It can be an arbitrary expression, 
like the argument to print. 
 
 FMT controls how the memory should be dumped, and consists of (up to) three components: 
 * A numeric COUNT of how many elements to dump 
 * A single-character FORMAT, indicating how to interpret and display each element 
 * A single-character SIZE, indicating the size of each element to display. 
 
x displays COUNT elements of length SIZE each, starting from ADDRESS, formatting them 
according to the FORMAT. 
 
There are many valid "format" arguments; help x in gdb will give you the 
full list, so here's my favorites: 
 
x/x displays elements in hex, x/d displays them as signed decimals, x/c displays 
characters, x/i disassembles memory as instructions, and x/s interprets memory as C 
strings. 
 
The SIZE argument can be one of: b, h, w, and g, for one-, two-, four-, and 
eight-byte blocks, respectively. 
 
If you have debug symbols so that GDB knows the types of everything you might want to 
inspect, p is usually a better choice, but if not, x is invaluable for taking a look 
at memory. 
 
 [~]$ grep saved_command /proc/kallsyms 
 ffffffff81946000 B saved_command_line 
 
 
 (gdb) x/s 0xffffffff81946000 
 ffffffff81946000 <>: "root=/dev/sda1 quiet" 
 
 x/i is invaluable as a quick way to disassemble memory: 
 
 (gdb) x/5i schedule 
 0xffffffff8154804a <schedule>: push %rbp 
 0xffffffff8154804b <schedule+1>: mov $0x11ac0,%rdx 
 0xffffffff81548052 <schedule+8>: mov %gs:0xb588,%rax 
 0xffffffff8154805b <schedule+17>: mov %rsp,%rbp 
 0xffffffff8154805e <schedule+20>: push %r15 
 
If I'm stopped at a segfault in unknown code, one of the first things I try is 
something like x/20i $ip-40, to get a look at what the code I'm stopped at looks like. 
 
A quick-and-dirty but surprisingly effective way to debug memory leaks is to let the 
leak grow until it consumes most of a program's memory, and then attach gdb and just x 
random pieces of memory. Since the leaked data is using up most of memory, you'll 
usually hit it pretty quickly, and can try to interpret what it must have come from. 

 
© 2011 Ksplice, Inc. 

gdb ほとんど使わないからなあ。

GDBハンドブック
GDBハンドブック

■_ 多言語

PerlやらRubyやらで同じことをやったのを見たような覚えが。

pts.blog: Multilingual programs in Haskell, Prolog, Perl and Python

Multilingual programs in Haskell, Prolog, Perl and Python 
 
This blog posts shows program source codes that work in multiple languages (including Haskell, Prolog, Perl, Perl and Python. 
 
Here is a program which works in Haskell, Prolog and Perl: 
 
$ cat >m1.prg <<'END' 
foo( {-1/*_} ) if!'*/%'; print "Hello, Perl!\n" if<<'-- */' 
}). :- write('Hello, Prolog!'), nl, halt. 
/* -} x) = x 
main = putStrLn "Hello, Haskell!" 
-- */ 
END 
$ perl m1.prg 
Hello, Perl! 
$ swipl -f m1.prg 
Hello, Prolog! 
$ cp m1.prg m1.hs 
$ ghc m1.hs -o m1 
$ ./m1 
Hello, Haskell! 
 
Here is a program which works in Haskell, Prolog and Python: 
 
$ cat >m2.prg <<'END' 
len( {-1%2:3} ); print "Hello, Python!"; """ 
}). :- write('Hello, Prolog!'), nl, halt. 
/* -} x) = x 
main = putStrLn "Hello, Haskell!" 
-- """ # */ 
END 
$ python m2.prg 
Hello, Python! 
$ swipl -f m2.prg 
Hello, Prolog! 
$ cp m2.prg m2.hs 
$ ghc m2.hs -o m2 
$ ./m2 
Hello, Haskell!

■_ 七言語七週間

でまあ昨日ようやく届いたわけですが。

Seven Languages in Seven Weeks: A Pragmatic Guide to Learning Programming Languages (Pragmatic Programmers)
Seven Languages in Seven Weeks: A Pragmatic Guide to Learning Programming Languages (Pragmatic Programmers)

The Pragmatic Bookshelf | Seven Languages in Seven Weeks
Contents and Extracts

Full Table of Contents

    * Foreword
    * Introduction
    * Ruby
    * Io excerpt
    * Prolog excerpt
    * Scala
    * Erlang
    * Clojure
    * Haskell
    * Wrap-up
    * Bibliography

言語ひとつで5日とか7日あるのかと思ったら、それぞれ DAY 3 までしかないみたい。 とりあえず前文読んだw

■_

■_

1.8.7
    rb_define_method(rb_cHash,"each", rb_hash_each, 0);
    rb_define_method(rb_cHash,"each_value", rb_hash_each_value, 0);
    rb_define_method(rb_cHash,"each_key", rb_hash_each_key, 0);
    rb_define_method(rb_cHash,"each_pair", rb_hash_each_pair, 0);
1.9.2
    rb_define_method(rb_cHash,"each_value", rb_hash_each_value, 0);
    rb_define_method(rb_cHash,"each_key", rb_hash_each_key, 0);
    rb_define_method(rb_cHash,"each_pair", rb_hash_each_pair, 0);
    rb_define_method(rb_cHash,"each", rb_hash_each_pair, 0);

ほう。こんなところから変わってたのか。

2011年01月26日

■_

・ダムエー
オリジン休載でも買う(連載終わったあとはわからんけど)。 安彦―庵野対談とか、教えてください富野ですは良かった。 これだけでも買う甲斐があったというもの。 教えてください富野ですはもうすぐ100回なんだねえ。
GUNDAM A (ガンダムエース) 2011年 03月号 [雑誌]

・D&D
ASCII.jp:昔懐かしいD&Dの「赤箱」が最新版になって復活!
トラベラーは…無理だろうなあ。

■_ ラッシュ

なにこの3月からの箱のこのラインナップ。 Amazon.co.jp: EMOTION the Best ブレンパワードDVD-BOX: 富野由悠季, 白鳥 哲, 村田秋乃, 朴ろ美, 渡辺久美子: DVD Amazon.co.jp: EMOTION the Best 聖戦士ダンバイン DVD-BOX1: 富野由悠季, 中原茂, 土井美加, 安宅誠, 川村万梨阿: DVD Amazon.co.jp: EMOTION the Best 聖戦士ダンバイン DVD-BOX2<最終巻>: 富野由悠季, 中原茂, 土井美加, 安宅誠, 川村万梨阿: DVD Amazon.co.jp: EMOTION the Best 重戦機エルガイム DVD-BOX1: 富野由悠季, 平松広和, 大塚芳忠, 本多知恵子, 川村万梨阿: DVD Amazon.co.jp: EMOTION the Best 重戦機エルガイム DVD-BOX2<最終巻>: 富野由悠季, 平松広和, 大塚芳忠, 本多知恵子, 川村万梨阿, 速水奨: DVD

もっとも、ブレンパワードは全巻買ってるし、ダンバインも前(の前?)の箱買ってるな。

…ときにキンゲは?

■_ 英語重要

なんだっけ、タイムマシンなんとかいうやつ?

推薦図書/必読書のためのスレッド 60

762 デフォルトの名無しさん [] 2011/01/26(水) 21:16:49 ID: Be: 
 数年ぶりにこの板にきたけど、まだこのスレあるのなw 
 2000年はじめの頃に学生で、今ではオッサンのシニアプログラマになったわけだけど、 
 ここで推薦されていた本を呼んでいたおかげでシニアに出世できたぜ。 
 ありがとな。 
 
 やっぱ勉強するプログラマとそうでないプログラマのスキルの差は歴然だわ。 
 若い子を見ていて有能な人とそうでない人の読書率の差は大きい。 
 
 オッサンからのアドバイスだけど、洋書についてはできれば原著を読んだ方がいい。 
 英語のスキルはプログラムスキルに直結するぜ。 
 
763 デフォルトの名無しさん [sage] 2011/01/26(水) 21:29:09 ID: Be: 
 >>762 
 なにか結果を見せてくれないと、 
 ここでそれを言っても、ふーんそう、で終わると思う 
 (言ってることは激しく同意する) 
 
 で、ふーんそう、で終わるならそれまでのヤツだな、 
 とか言うレスがついて本当に終わる 
 
 なにかちゃんとした結果を見せてくれれば、 
 すげー、どんな本読んだの? とか、それどこに載ってた? とか言って 
 スレのタイトルらしくなるんだが 
 
764 デフォルトの名無しさん [] 2011/01/26(水) 21:37:58 ID: Be: 
 >>763 
 具体例かー。俺はゲーム系の研究職なので、実績を書くと身元がバレるのが怖いのでメジャーなところを紹介しておく。 
 
 ゲーム屋はやったもん勝ちなので、出来る限り技術は新しい方がいい。 
 例えば以下の本とかは1年遅れくらいで翻訳される。 
 
 http://www.realtimerendering.com/ 
 http://www.realtimecollisiondetection.net/ 
 
 で、1年後だとたいてい他社が実装済みで、売りがなくなったりする。 
 こういう本や論文をいち早く手に入れて、社内に宣伝すると評価を得られるし、 
 なによりも製品のクオリティが上がるのでお客さんにとって良いものを提供できる。 
 
 こういう感じでOK? 
 
765 デフォルトの名無しさん [] 2011/01/26(水) 21:44:35 ID: Be: 
 ちなみに今のゲーム屋のトレンドは、リアルタイムインタプリタ。 
 ゲーム機がリッチになってきているので、超高水準言語で開発した方がターンアラウンドが短い。 
 日本のコンパイラ、インタプリタ、VM関連の書籍状況は若干貧弱なのよねー。 
 
 で、上の方でその辺の議論している人がいたけど、 
 同じ会社の人じゃないかと笑っちゃったw 
 
766 デフォルトの名無しさん [sage] 2011/01/26(水) 21:46:44 ID: Be: 
 この業界狭いから気をつけろよ 
 
767 デフォルトの名無しさん [] 2011/01/26(水) 21:49:37 ID: Be: 
 >>766 
 アドバイスさんきゅ。最低限NDAは遵守するので大丈V。 

■_ How to learn a new language

【超初心者】プログラミング質問スレ【基礎】part3

672 デフォルトの名無しさん [sage] 2011/01/26(水) 17:34:33 ID: Be: 
 漠然とした質問ですみません。 
 むしろそもそもスレ違いだったらごめんなさい。 
 
 ここの先輩方って、新言語の勉強をする時にはどうやって勉強していましたか? 
 
 今年から仕事でプログラムに接することになり、技術力が無いとは言えない立場ですが、 
 自習しても理解できない点が多く、教わる相手もおらず、学習が行き詰っています。 
 
 先輩方が今の技術を得るまでに超えてきた『学び方』のアドバイスなど 
 何かヒントを頂ければと思い書き込んでみました。 
 
 役に立たないのは辛いよ・・・。 
 
673 デフォルトの名無しさん [sage] 2011/01/26(水) 18:01:32 ID: Be: 
 ぐぐれ 
 
674 デフォルトの名無しさん [sage] 2011/01/26(水) 18:07:59 ID: Be: 
 わからない部分の前にわかったつもりの部分がある 
 アホな質問のほとんどはそれだ 
 
 定評ある本で定義をしっかり覚えて 
 例題なり演習問題なり、実際に処理系を触りながら解いていくしかない 
 
675 デフォルトの名無しさん [sage] 2011/01/26(水) 18:11:20 ID: Be: 
 これまでどんな言語をやってて今回何をやらされようとしているのかとか、 
 実はプログラミングは初めてですとか、そのぐらいは書けよな 
 
676 デフォルトの名無しさん [sage] 2011/01/26(水) 18:19:14 ID: Be: 
 >>672 
 言語によっては講習会で説明を聞く。 
 
677 デフォルトの名無しさん [sage] 2011/01/26(水) 18:51:09 ID: Be: 
 >>672 
 基本的には入門書→その分野で定評のある本 
 短いコードをたくさん書きながら読む 
 入門書でつまづくようなら、複数の入門書を手にして 
 並行的に読むといい(わからない箇所だけ複数の本やWebにあたる) 
 
678 デフォルトの名無しさん [sage] 2011/01/26(水) 18:59:28 ID: Be: 
 あー分かる。 自然とそうなる。 
 ただ時間がないないって焦ると日本語の意味さえ分からなくなってきて大変。 
 仕事じゃなくて趣味や興味で勉強してると自分に思い込ませて頑張った。 
 
679 デフォルトの名無しさん [sage] 2011/01/26(水) 19:05:21 ID: Be: 
 はじめのうちは本当につまらないことしかできないし 
 その上よくわからない用語をがんがん使われるとお手上げ 
 ある程度進んでくると突然面白くなる 
 
680 デフォルトの名無しさん [sage] 2011/01/26(水) 19:32:41 ID: Be: 
 初心者に高圧的な奴は間違いなく童貞 
 
681 デフォルトの名無しさん [sage] 2011/01/26(水) 19:42:54 ID: Be: 
 あるアルゴリズムを複数の言語で実装して比べてみる 
 新しい言語に出会う度にそのレパートリーを増やす 
 そうするうちに言語の違いなんて大した問題じゃないことが判る 
 VBやPerlは糞だから絶対使いたくない 
 
682 デフォルトの名無しさん [sage] 2011/01/26(水) 19:56:47 ID: Be: 
 >>676 
 ふた昔も前のこと私が34才の時、LISPの講習会に参加した。 
 講師は武蔵野通研の奥野博氏と京大の萩谷昌己君。私は萩谷君の 
 機知に富み、聡明かつ柔和な人柄とその受け答えに、羨望を念を 
 禁じ得なかった。うちの社員にこんな人材が欲しいなぁとも本気 
 で思った。同時に16-7才からこの道を志さなかったことを悔やんだ。 
 こんな刺激は本ではなかなか得られない。最近の講習会事情は疎い 
 けれど。 
 
683 デフォルトの名無しさん [sage] 2011/01/26(水) 20:28:02 ID: Be: 
 >>672 
 自分の持っている技がどう書けるかプログラムを実際に書くことと、 
 レベルの高いサンプルプログラムで言語特有の言い回しを覚えること。 
 あとは、リファレンスで武器の確認。 
 
684 デフォルトの名無しさん [sage] 2011/01/26(水) 21:26:49 ID: Be: 
 >>672 
 論よりrun。 
 

■_ Powerd by Prolog

みっつめ。

Prologでまったり Part4

775 デフォルトの名無しさん [sage] 2011/01/02(日) 08:22:56 ID: Be: 
 初夢。 
 春に、「Programming for Artificial Intelligence」の新版がでる! 
 
776 デフォルトの名無しさん [sage] 2011/01/26(水) 12:48:16 ID: Be: 
 PrologTipsの人のサイトって消えちゃった? 
 
777 デフォルトの名無しさん [sage] 2011/01/26(水) 15:04:15 ID: Be: 
 >>776 
 ごめん。起動するの忘れてた。 
 apacheではなく、Prologサーバなんです。 
 
778 デフォルトの名無しさん [sage] 2011/01/26(水) 17:31:30 ID: Be: 
 >>777 
 わざわざありがとう 
 そしてPrologでサーバーまで作るとは… 
 
779 デフォルトの名無しさん [sage] 2011/01/26(水) 19:12:37 ID: Be: 
 ワロタw 
 Prologサーバーとかすごいなー 
 
780 デフォルトの名無しさん [sage] 2011/01/26(水) 19:24:17 ID: Be: 
 >>779 
 PrologインタプリタがTCP/IP経由のサーバになっていて、 
 たまたまポート番号80で動いているっていうだけw 
 

Prolog でWebサーバーかあ。

■_

■_ キターッ

■_ しかし

なんなんだこの、時間が足りない感は。

[ruby-dev:43111] Hashのイテレーション中の新規キー追加
[ruby-dev:43118] Re: Hashのイテレーション中の新規キー追加
[ruby-dev:43121] Re: Hashのイテレーション中の新規キー追加

[ruby-list:47766] Hashイテレーション中の新規キー追加
[ruby-list:47767] Re: Hashイテレーション中の新規キー追加
[ruby-list:47768] Re: Hashイテレーション中の新規キー追加
[ruby-list:47769] Re: Hashイテレーション中の新規キー追加
[ruby-list:47772] Re: Hashイテレーション中の新規キー追加
[ruby-list:47774] Re: Hashイテレーション中の新規キー追加
[ruby-list:47775] Re: Hashイテレーション中の新規キー追加
[ruby-list:47776] Re: Hashイテレーション中の新規キー追加
[ruby-list:47777] Re: Hashイテレーション中の新規キー追加
[ruby-list:47778] Re: Hashイテレーション中の新規キー追加

[ruby-core:23614] [Bug #1535] Hash#merge! Inside Iterator Can Cause RuntimeError
Bug #1535: Hash#merge! Inside Iterator Can Cause RuntimeError
http://redmine.ruby-lang.org/issues/show/1535

[ruby-core:23617] [Bug #1535] Hash#merge! Inside Iterator Can Cause RuntimeError
[ruby-core:23626] [Bug #1535] Hash#merge! Inside Iterator Can Cause RuntimeError
[ruby-core:23629] [Bug #1535] Hash#merge! Inside Iterator Can Cause RuntimeError
[ruby-core:28189] [Bug #1535] Hash#merge! Inside Iterator Can Cause RuntimeError
[ruby-core:28190] Re: [Bug #1535] Hash#merge! Inside Iterator Can Cause RuntimeE...
[ruby-core:28193] Re: [Bug #1535] Hash#merge! Inside Iterator Can  Cause Runtime...

[ruby-core:23628] [Bug #1539] [Docs] Hash#rehash Raises RuntimeError Not IndexError
[ruby-core:25750] [Bug #1539](Closed) [Docs] Hash#rehash Raises RuntimeError Not...

↑この辺を基に書こうと思ってたのだけど。

2011年01月25日

■_

プーねこの新刊が出るらしい

■_ どうでもいいこと

サイバーエージェントとミクシィが合弁会社を設立mixiアプリプラットフォーム向けソーシャルアプリ事業会社 株式会社グレンジの設立について « 株式会社ミクシィ

プレスリリース 
 
サイバーエージェントとミクシィが合弁会社を設立 
mixiアプリプラットフォーム向けソーシャルアプリ事業会社 株式会社グレンジの設立について 
 

「合弁会社」って

ごうべんがいしゃ【合弁会社】の意味 - 国語辞書 - goo辞書

ごうべん‐がいしゃ〔ガフベングワイシヤ〕【合弁会社】 
 
 外国資本と国内資本との共同出資によって設立され、共同で経営される会社。
合弁会社 経営用語集

合弁会社 
 
合弁会社とは、国内企業と外国企業が共同出資をして設立し、共同経営を行う会社のことです。

だと思ってたんだけど違うの? それともサイバーエージェントかミクシィのどっちかが「外国資本」?

合弁会社とは - はてなキーワード

合弁会社 ごうべんがいしゃ (一般) 

 
複数の異なる企業などが出資して設立される会社のこと。合弁事業を行うことを目的として設立
したりする。

ふむ。

■_ もなど

英語圏でもモナドはブログネタになり続けているようで。

Room 101: Maybe Monads Might Not Matter

Maybe Monads Might Not Matter 

This post isn't really about the Maybe Monad of course. It is more focused on the 
State Monad, but I have a weakness for alliteration. 

What do 

  space suits 
  nuclear waste containers 
  romantic conquests 
  monsters 
  macros 
  containers 
  conversations 

have in common? They've all been used as metaphors for monads. 
 
Last time I looked, the Haskell wiki listed 29 tutorials on the subject, and that is 
where all these allusions come from. 

略

■_

謎めいている

Shadowflux: JavaScript ( (__ = !$ + $)[+$] + ({} + $)[_/_] +({} + $)[_/_] )


I saw it in a slide deck from BlackHat DC 2011. Called XSS Street-Fight. Most of the 
presentation was dry JavaScript /mod_security, but this caught my eye. 
 
($=[$=[]][(__=!$+$)[_=-~-~-~$]+({}+$)[_/_]+ 
($$=($_=!''+$)[_/_]+$_[+$])])()[__[_/_]+__ 
[_+~$]+$_[_]+$$](_/_) 
 
Care to guess what that does? 
 
How about if I type it like this. 
 
($=[$=[]][(__=!$+$)[_=-~-~-~$]+({}+$)[_/_]+ 
($$=($_=!''+$)[_/_]+$_[+$])])()[__[_/_]+__ 
[_+~$]+$_[_]+$$](document.cookie) 
 
That's right this is an alert() if it lands anywhere in 
an executable section of JavaScript/dom it pops up the cookie. 
 
Go ahead and put it in a script tag in your browser it will pop up a "1" 
 
That's when I couldn't put this down. 
 
First there are really two lines here. 
 
($ = [ $=[]] [ (__ = !$ + $ )[ _ = -~-~-~$] + ({} + $)[_/_] + ( $$ = ( 
$_ = !'' + $)[_/_] + $_[+$] ) ] )() 

(さくっと略)

 
[__[_/_]+__[_+~$]+$_[_]+$$](_/_) 
 
$ = 0 
_ = 3 
__ = "false" 
$_ = "true" 
$$ = "rt" 
 
[__[_/_]+__[_+~$]+$_[_]+$$](_/_) 
 
becomes 
[__[1] + __[3 + -1] + $_[3] + $$)(1); 
 
becomes 
["false"[1] + "false"[3 + -1 ] + "true"[3] + "rt"] (1) 
 
[ a + l + e + r + t ](1) 
 
alert(1) 
 

■_

2011年01月24日

■_

なんというか。
日経ソフトウエア 2011年 03月号 [雑誌]
掲載のYさんの連載。

文字列を比較するstrcmp関数のところにあったプログラム片。

リスト5
int strcmp(const char* str1, const char* str2) {
  int ans;

   while (-1) {
      ans = *str1 - *str2;

      if (ans > 0) break;

      if (ans==0&&*str1=='\0'&&*str2=='\0') break;

      if (ans < 0) break;

      str1++;
      str2++;
   }
}

↑これが Yさん作で、↓がとあるコンパイラー付属のライブラリのソース

リスト6
int __cdecl strcmp (
  const char * src,
  const char * dst
)
{
    int ret = 0;

    while (!(ret=*(unsigned char *)src-*(unsigned char *)dst)&&*dst)
        ++src, ++dst;

    if (ret < 0)
        ret = -1;
    else if (ret > 0)
        ret = 1;

    return( ret );

}

↑をうけてYさんが書き直したのが↓

リスト8
int strcmp(const char * str1, const char *str2)
{
    int ans;

    while (((ans=*str1-*str2)==0)&&*str!='\0') {
        str1++;
        str2++;
    }

    return ans;

}

なんで戻り値を保持する変数が 「ans」なんだ。とかいうのは置いといて、 ちと気になることがあったので調べてみた。

strcmp

NAME 
 
 strcmp - compare two strings 

(略)

The sign of a non-zero return value shall be determined by the sign of the difference 
between the values of the first pair of bytes (both interpreted as type unsigned char) 
that differ in the strings being compared. 
 

both interpreted as type unsigned charとあるんだから、 char のまんま引き算やっちゃあいけないんじゃないですかねえ。

条件判定のところもつつきたいけどいいや。

あ、引用はしないけど、本文に strcmp は「辞書順で比較する」ようなことをが 書いてあったり。ちょっとうかつじゃないかなあ。

■_

The Evolution of a Python Programmer : Aleks' Domain で。

The Evolution of a Python Programmer : Aleks' Domain


EXPERT PROGRAMMER 
 
from c_math import fact 
print fact(6) 
 

BRITISH EXPERT PROGRAMMER 

from c_maths import fact 
print fact(6) 

© Aleks' Domain. Powered by WordPress and Manifest 

の、britsh のところがよくわからんというツイートが。

Twitter / @Atsuo Ishimoto: Britishのネタがわからん RT @t2y: コ ...

Britishのネタがわからん RT @t2y: コメントもおもしろい RT @lanius: おもろい
「The Evolution of a Python Programmer」 http://ow.ly/3Ix2P

やっぱり同じように考える人は海の向こうにもいるようで、

The Evolution of a Python Programmer : Aleks' Domain : programming

 
about the difference between British and US programmer: am i too blind to see the 
difference or is t the joke that there is no difference between both codes ? 
 

"maths" 
 

maths vs math 
 
 
Here (US), people say 'math'. Elsewhere (seemingly everywhere else from my admittedly 
limited exposure), people say 'maths'. It's a subtle difference, but tends to strike a 
nerve when you're not used to it. 

 
the only difference is "c_maths" instead of "c_math" 
 

イギリス英語とアメリカ英語で綴りが違うとか言う話と同類?

■_ 砂糖に気をつけろ

Beware of Ruby Sugar — Andy Lindeman


Yesterday, I posted a tip about iterating through time with Ruby and Rails/ActiveSupport. 

Originally, I posted this code. This code is actually not valid in Ruby 1.9 anymore. 
 
# Steps day-by-day from today until 5 days from now 
Range.new(Time.now, 5.days.from_now).step(1.day) do |time| 
 puts time 
end 
 
This code looks amazingly compact and incredibly idiomatic … right? 
 
Well, not so “fast”. Take a look at the API documentation for Range#step: 

(略)

In the end, I recommend this code: 
 
now = DateTime.now 
 
# Second argument defaults to 1, but shown for clarity 
now.step(now + 5, 1) do |time| 
 puts time 
end 
 
DateTime has its own #step instance method which can be much more specific about its 
implementation than Range#step which must operate correctly on nearly every type of 
enumerable object. 
 
Final thought: Sometimes abstractions and duck typing are great things, but be 
especially careful with methods that accept any object that implements a very limited 
public API (in this case, Range with objects that respond to #succ). In many cases, 
using only this limited API results in very bad inefficiencies. 

便利な(わかりやすい、書きやすい)記法は遅かったりするから気をつけようね。とか。

■_

■_

この辺読んでる暇がががが

2011年01月23日

■_

プログラミング原論 ふと気になったのでぐぐってみたのですが、 探し方が悪いのか書評とか感想の類が全然引っかからない。 読まれてないの? って自分も読んでおいてほとんどなにも書いてないわけですが。 これくらい? → 「プログラミング原論」の長い道のり。ようやく二章まで | hippos-lab::blog

magorokutv on USTREAM: Android,、ぐだ生、電子工作、beagleboard、unix. (現在は見られません) 生のバイナリコードがソース中にあったとは

■_ Using averages - a common performance measurement mistake

Using averages - a common performance measurement mistake

Using averages - a common performance measurement mistake
平均を使う 性能測定でよくある間違い

Summary:
when people want to get a more accurate result when benchmarking a performance of given
piece of code they often run the same test multiple times and use an average as a final
benchmark result. It's a mistake: using the time of the fastest run is more accurate.

与えられたコード片の性能のベンチマークを取ったときに
人々がより正確な結果を得ようとした場合には
往々にして彼らは、同じテストを複数回実行して
それを平均したものをベンチマークの最終結果としてしまいます。
It's a mistake: using the time of the fastest run is more accurate.
しかしこれは間違っていて、最速の時間を使うのがより正確なのです。

By definition, a performance test must be deterministic: given the same inputs it'll 
execute exactly the same number of machine instructions, read and write the same amount
of data to/from disk etc. If it isn't deterministic, benchmarking it is pointless.

定義により、性能テストはdeterministicでなければなりません:
同じ入力を与えたならばまったく同じ数の機械命令で実行され、
同じ量のデータの読み書きをディスクなどに対して行います。
もしこれがdeterministicでないのなら、ベンチマークを行うことはpointlessです。

We all know, however, that execution time is not deterministic. Why is that?

しかしわたしたちは皆、実行時間が deterministic であることを知っています。
それはなぜでしょうか?

Multi-tasking nature of the operating system is to blame. Your code is only one of the 
many processes that compete for fixed resources like cpu time and i/o bandwidth. 
Operating system will interrupt your program and start executing some other code, at 
random times and for unpredictable amount of time.

オペレーティングシステムのマルチタスクの性質は to blame です。
あなたのコードは、CPU 時間や I/O の帯域のような fixed resources を compete する
多くのプロセスのうちのたった一つなのです。
オペレーティングシステムはランダムな時間に、予測不能な期間
あなたのプログラムに割り込んで他のコードを実行するでしょう


If you measure just the time of execution, like most benchmarking methods do, it'll 
include not only the execution time of your code but also of other programs executed 
by operating system during that particular test run.

もしあなたが実行時間だけの計測をしたならば、大部分のベンチマーク手法がそうであるように
それにはあなたのコードの実行時間だけでなく特定のテストが実行されている間にオペレーティ
ングシステムによって実行されている他のプログラムのものも含むことになるでしょう。


The same applies to other shared resources like a hard-drive: the benchmarked program 
asks the OS to read a piece of data from disk but so do other programs. The OS decides 
who gets to do I/O first in an unpredictable and unaccountable way.

同じことを、たとえばハードドライブのような他の共有リソースにも適用します。
ベンチマークプログラムはディスクからデータを読み出すために OSに依頼しますが、
それは他のプログラムも行うことです。
OS は誰が最初にI/Oを得るのかを unpredictable で unaccountable なやり方で決定します


You have little control over that behavior. You can think of execution time of your 
test as consisting of 2 components:

あなたはその振る舞いに倒してはそれほど制御権を持っていません。
テストの実行時間は次に挙げる二つの要素の合計と見なせます。


    * the deterministic execution time of only your code, which would happen if your 
      process had exclusive access to all resources like cpu and hard-drive

      あなたのプロセスがCPUやハードディスクのようなすべての資源を排他的に
      占有できた場合のあなたのコードのみの決定可能な実行時間

    * random, unpredictable execution time of all other programs that OS decided to 
      run during that particular test run

     特定のテストを実行している間にOS が実行するのを決定した、
     ランダムで予測できない実行時間を持つ他のすべてのプログラム


In other words, the benchmarked time is: the time your're interested in + a random 
overhead attributable to other processes.

言い換えると、計測した時間はこういったものです:
あなたが関心を持っていた時間 + 他のプロセスに関連するランダムなオーバーヘッド


This model explains why you should use the time of the fastest test run: it's the 
best approximation of the running time that is attributable only to your code (and 
with the smallest part attributable to other random processes).

このモデルはなぜ最速のテスト結果をあなたは使うべきなのかを説明します。
それは、あなたのコードそのもの実行時間(そして他の random processs の影響が
最小となっている) の best approximation なのです。

Other coping mechanisms when doing performance tests involve trying to minimize the 
random component by shutting down as many processes as possible, so that less things 
will get in the way.

■_ λ

推薦図書/必読書のためのスレッド 60

680 デフォルトの名無しさん [sage] 2011/01/23(日) 01:08:06 ID: Be: 
 「関数プログラミング」以外には、関数型言語の哲学が学べる和書ってないの? 
 無いなら洋書でもいいけど、なにかある? 
 
 あるいは、関数型言語と数学の繋がりを述べた本でもいい 
 
684 デフォルトの名無しさん [sage] 2011/01/23(日) 05:24:07 ID: Be: 
 >>680 
 関数プログラミングのどういう点が不満? 
 
685 デフォルトの名無しさん [sage] 2011/01/23(日) 05:38:18 ID: Be: 
 関数型言語はやろうやろうとは思っても現時点では好きなわけでもないし 
 必要に迫られることもないからずっと先送りしてる。たぶん一生やらないだろうな 
 
686 デフォルトの名無しさん [sage] 2011/01/23(日) 09:26:30 ID: Be: 
 それでいいと思う 
 でも、これからメジャーな言語に取り入れられる機能は関数型の機能ばかりだから 
 そのうち嫌でも関数型言語の概念に触れることになるだろうけど 
 
689 デフォルトの名無しさん [sage] 2011/01/23(日) 12:04:33 ID: Be: 
 >>684 
 不満は全くない 
 
 面白かったから、別の本も読んでみたい 
 
690 デフォルトの名無しさん [sage] 2011/01/23(日) 15:13:07 ID: Be: 
 まあ定番のSICPでも読んでおけばいいんじゃない。 
 関数型言語の勉強には「まったく」ならないけど、 
 大雑把な方向性は掴めるだろうし、初学者向けに冗長だから読むのも楽だし 
 
 最低限、再帰とMapとクロージャは身につくしね 
 
691 デフォルトの名無しさん [sage] 2011/01/23(日) 15:46:41 ID: Be: 
 >>690 
 ごめん、Haskell は普通に使ってる(また SICP も読んだ) 
 
 なんて言うのかな 
 
 入門書ではないし、かと言って RWH のような実用ネタの本でもなくて、 
 もっと学術的なネタが載ってる本が読みたい(役に立つかはどうでもいい) 
 
 たとえば、数学者などからみて関数型言語ってどうなの? 
 計算機科学者からみて関数型言語ってどうなの? とか 
 証明器として使うには今の関数型で十分? 何が足りない? とか 
 
692 デフォルトの名無しさん [sage] 2011/01/23(日) 15:56:40 ID: Be: 
 興味本位だが、Haskellを普通に使ってるレベルの人への書籍のアドバイス俺も聞きたい 
 
693 デフォルトの名無しさん [sage] 2011/01/23(日) 15:58:26 ID: Be: 
 >>691 
 ラムダ計算の本とかは? 
 
694 デフォルトの名無しさん [sage] 2011/01/23(日) 15:58:56 ID: Be: 
 >>691 
 Haskellの行き着く先はこういう分野か 
 
 経験15年のOCaml ユーザーが Haskell を仕事で半年使ってみた - Oh, you `re no (fun _ → more) 
 http://d.hatena.ne.jp/camlspotter/20101212/1292165692 
 
695 デフォルトの名無しさん [sage] 2011/01/23(日) 16:09:18 ID: Be: 
 haskellスレや関数型スレ、米アマゾンの方が人がいると思う 
 
697 デフォルトの名無しさん [sage] 2011/01/23(日) 16:23:55 ID: Be: 
 米アマゾンはLISP新刊にレビューが続々付くくらいだからな 
 
698 デフォルトの名無しさん [sage] 2011/01/23(日) 17:11:15 ID: Be: 
 いやだから、ほしいのは Haskell 限定じゃないって 
 べつに限定でもいいけど、できればもっと広いものだから、ここで聞いた 
 
 関数型言語というプログラミング言語の考え方とか役割とか、 
 数学などの他分野との関わりとか、あと意味論とかの本でもいいけど 
 
 >>693 
 「Lambda-Calculus and Combinators an Introduction」 
 を読んで Lambda 計算本としてはとても分りやすくてためになったが、 
 関数型言語は Lambda 計算の考え方をどのように取り込んでるのか、 
 取り込む上で何が問題となったかなどの話は載ってなかった 
 
 >>696 
 それって、本を探してる人にたいして 
 Amazon のトップページの URL を紹介するのとほとんど変わらないよ 
 せめておすすめの論文を何か紹介してほしいんだけど 
 
699 デフォルトの名無しさん [sage] 2011/01/23(日) 17:13:55 ID: Be: 
 >>698 
 お前の方が詳しいよ。さっさとオススメの本紹介しろや。タイトルだけじゃなくどこが良かったかもな 
 
700 デフォルトの名無しさん [sage] 2011/01/23(日) 17:15:07 ID: Be: 
 じゃ、その方向で 
 
701 デフォルトの名無しさん [sage] 2011/01/23(日) 17:17:35 ID: Be: 
 >>698 
 お前が知りたいのは書籍じゃなくて論文レベルの話だからだろ 
 大学教授にメル凸しろや 
 
703 デフォルトの名無しさん [sage] 2011/01/23(日) 17:21:08 ID: Be: 
 >>698 
 この辺から論文探せばいいんじゃね? 
 ttp://www.icfpconference.org/ 
 
704 デフォルトの名無しさん [sage] 2011/01/23(日) 17:36:12 ID: Be: 
 >>701 
 こういうのは論文レベルにしか無い話なのか 
 普通に教科書と一般書の間ぐらいので何かあると思ってた 
 
706 デフォルトの名無しさん [sage] 2011/01/23(日) 17:43:18 ID: Be: 
 >>699 
 私の方が誰と比べて何の分野で詳しいと言うのだ? 
 
 > さっさとオススメの本紹介しろや。タイトルだけじゃなくどこが良かったかもな 
 
 私の気分で漠然と奨めても、あなたに良いねと言ってもらえる自信はない 
 どのような分野のどんなタイプの本を求めているのだ? 
 それが私の知識とマッチしていたら丁寧に紹介しよう 
 
707 デフォルトの名無しさん [sage] 2011/01/23(日) 17:44:51 ID: Be: 
 >>706 
 お前だってこのスレで勧めらた本に全然満足してねーじゃねーかw 
 それは読んだとか、それは違うとか 
 
708 デフォルトの名無しさん [sage] 2011/01/23(日) 17:46:29 ID: Be: 
 >>705 
 例えば「コンピュータサイエンス入門 論理とプログラム意味論」とか、 
 「アルゴリズムデザイン」などが一般書 
 
 大学生とか学者ではないけど、 
 計算機科学とかプログラミングに興味を持つ一般人が読む本 
 
712 デフォルトの名無しさん [sage] 2011/01/23(日) 17:50:42 ID: Be: 
 >>707 
 たしかに >>690 には悪いことをした 
 初めに初学者ではない事を伝えておけばよかった 
 
 しかしその後、「タイトルだけじゃなくどこが良かったかも」を含めて、 
 私になにか書籍のタイトルを紹介した者はいない 
 
 よって、満足しないもなにも、評価しようがない 
 
713 デフォルトの名無しさん [sage] 2011/01/23(日) 17:52:17 ID: Be: 
 だから、自分で探せよ情弱。テンプレを見てみろ情弱 
 初学者にお前のような人間が本を紹介するスレだって気づかないわけ情弱 
 専門スレを検索できないの情弱 
 
714 デフォルトの名無しさん [sage] 2011/01/23(日) 17:55:50 ID: Be: 
 普通にGoogleとかMicrosoft Researchとかを追っかけるのが先では? 
 あの辺の開発者で(ヘジも関数型のファンを自称しているし)関数型言語の未来について、 
 ある程度研究し尽くしたビジョンを持って開発していない奴はいないわけなので、 
 出てくる製品を見ていれば、大体の方向性はわかるはずのものでしょう。 
 
715 デフォルトの名無しさん [sage] 2011/01/23(日) 17:58:39 ID: Be: 
 >>711 
 あなたは「コンピュータサイエンス入門 論理とプログラム意味論」を 
 読んだことはあるの? 

 読んでもいないのに、紹介文に書かれた事をそのまま鵜呑みにして、 
 学者や研究者「しか読めない、ためにならない」本だと思い込んでる? 

 コンピュータプログラムというものに興味を抱いた者なら、 
 学生や研究者じゃなくても、誰でも読める本だよ 

 たとえば、3DCG の物理演算に興味を持った一般人が、 
 「PHYSICS-BASED ANIMATION」を読むようななものだよ 
 あれも教科書のように見えて、興味のある一般人が普通に読めるレベル 

725 デフォルトの名無しさん [sage] 2011/01/23(日) 19:02:42 ID: Be: 
 じゃあ、私の欲しかったのは書籍という形では存在していなく、 
 論文でしか情報は手に入らなそうだというアドバイスを受けたとしいうことで、 
 この話は終わりにします 
 (今までも時々論文を漁ってましたが、もう少しがんばって探してみます) 
 
 
 別の話ですが、OSを自作してみよう的な本はいくつか出てるのですが、 
 エミュレータを自作してみようという本は何か無いでしょうか 
 X86 マシンとか ARM マシンをエミュレートしてみようという感じの入門書です 
 
 あるいは、題材は架空のマシンでもいいです 
 
 CPU の仕組みとか命令セットとかメモリの扱い方とかの本は個々にあるのですが、 
 マシンをエミュレートするとはどういうことか、どうするか、 
 といったことをプログラムの視点で述べた本を探してます

そういや、TAPL にもコンビネーター出てきたなあ。

■_ Python is better than Perl6

あとで…できたらいいなあ。

Everything Sysadmin: Python is better than Perl6

Python is better than Perl6 
 
In all the time I've been waiting for Perl6 I learned Python and, guess what? I like 
Python better. 
 
I'm a big fan of Perl. I have been since 1991, Perl 4.032. That was 19.5 years ago. 
Back then learning perl was "radical" and "fringe". Backk then it 
wasn't acceptable at most companies to use Perl. Since then perl was gone from being 
revolutionary to accepted broadly. Initially it was mostly used by sysadmins but the 
invention of the web (and therefore CGI scripts), saved it. Prior to this there wasn't 
much need for heavy string processing (awk was sufficient) or database connectivity 
(who could afford $50,000 for Oracle?). However with Perl's CGI module and MySQL 
integration using Perl became "obvious". Heck, you might say that "CGI 
saved Perl from irrelevance". I was proud to be an early adopter of Perl. Like 
the apes that learned to use tools before the other primates, it gave me an 
evolutionary advantage that was undeniable. 
 
Perl4 was good. Perl5 was great. There were 3 things I wanted in Perl6: Cleaner OO 
support, cleaner grammar, and the third thing? Well, I wanted it to ship. 

以下略


■_

■_

2011年01月22日

■_

とある魔術の禁書目録 II、BD揃えるかまだ悩んでたり。 イデオンの劇場版 BDとか絶望BOX(マテ)とかあったりするんでお金がないってのが。 みんなビンボがわるいんや(だっけ?)

行ってきた。 LLVM 勉強会第三回 : ATND

・miniperl
ビルドするときに、miniperl みたいに一度サブセット(というのか?)を作ってから それを使って本命を作るという手順を踏むようになったのって Perl 5が最初だろうか。 と思ったり。あ、手作業で作るというのではなく、ソースコードから作るときに そういうステージ分けになっているというものです。

買った
栄光なき天才たち2010 (ヤングジャンプコミックス)
栄光なき天才たち2010 (ヤングジャンプコミックス)
「天才騎手(ジョッキー)」というと武豊が真っ先に上がる世代だったり>わし

■_ LLVM勉強会

で、ほぼ予備知識ゼロの状態でいってきたのですが、 タロタローグ ブログ | LLVM勉強会に参加して、頭のてっぺんから???をばら撒いてきた。 の内容くらいは抑えておいてから行ったほうが良かったかも。

LLVMの中間言語 - LLVM wiki
LLVMの中間言語 

LLVMおよび周辺ツールは、中間言語を幾つも内包し、 
それぞれの中間言語を高レベルな中間言語から低レベルな中間言語に順に変換する。 
LLVMの特長は、BitCodeの完全な仕様が公開されているため、BitCodeへの変換機を作れば、LLVMの資産を活用できる。 
※ライセンスもGNUではなく、apacheライクなので、企業にも優しい。 
 
AST 
clangはプログラミング言語を字句・構文解析し、clang固有の抽象構文木(Abstract Syntax Tree)に変換する。 
ASTはTreeであり、コンテキストを保持し、パターンマッチがしやすい構造になっている。 
 
BitCode 
リファレンスも公開されている、LLVMメインの中間言語。 
静的単一代入(SSA Static single assignment)形式である。 
大規模な変換(最適化)をやりやすく、低コストで解析、変換を行うことができる。 
その理由はuse-def連鎖と支配関係の、解析とメンテナンスが容易なため。 
ASTで保持していたコンテキストが失われており、プログラミング言語のループ構文が失われている。 
パターンマッチがし難い。 
 
SelectionDAG 
llc内部で命令選択する際に使われる、無閉路有向グラフDirected acyclic graph型の中間言語。 
パターンマッチがしやすく、グラフ構造の部分的な組み換えみたいな変換はしやすい。 
 
MachineInstr 
llc内部で使われる、レジスタ割り付けや命令スケジューリング、アセンブラ変換用の中間言語。 
3番地および2番地コードの中間言語。アセンブラに変換しやすい。 
BitCodeよりも低レイヤー向けであり、1命令ごとの粒度が小さい。 
 
 
コンパイルの流れ 
 
 1. clangがソースコードを読み込み、BitCodeを出力する。 
 1. 字句解析、構文解析、意味解析を行い、AST形式に変換する。 
 2. 要望に応じて、AST形式の解析や付加情報追加を行う。 
 3. AST形式からBitCodeへ変換する。 
 2. optがBitCodeを読み込み、最適化を行い、BitCodeを出力する。 
 1. Moduleレベルの最適化 
 2. CallGraphSCCレベルの最適化 
 3. Functionレベルの最適化 
 4. Loopレベルの最適化 
 5. BasicBlockレベルの最適化 
 3. llvm-ldがBitCodeを多数読み込む、最適化を行い、1つのBitCodeを出力する。 
 1. 一つのModuleにまとめる 
 2. Module内で、Link Time Optimizationを行う 
 4. llcがBitCodeを読み込み、最適化を行い、アセンブラを出力する。 
 1. BitCodeでの最適化および変換の前準備を行う。 
 2. BitCodeから抽象SelectionDAG形式に変換する。 
 1. 抽象SelectionDAG形式での最適化を行う。 
 2. 抽象SelectionDAGから、ターゲットアーキテクチャ向けの具象SelectionDAG形式に変換(Legalize)する。 
 3. 具象SelectionDAG形式で、最適化を行う。 
 4. 具象SelectionDAG形式で、命令の選択とスケジューリングを行う。 
 3. 具象SelectionDAG形式から、MachineInstr形式に変換する。 
 4. MachineInstr形式で、最適化を行う。 
 5. MachineInstr形式で、レジスタ割り付けを行う。 
 6. MachineInstr形式で、関数呼び出しの前後のスタック周りの処理を挿入する。 
 7. MachineInstr形式で、最適化を行う。 
 8. MachineInstr形式からターゲットアーキテクチャのアセンブラに変換する。

随分とたくさんステージがあるのだなあとびっくり。 BitCode なんてのも初めて知った。

会場で調べて出てきたリンクとか。

ぼちぼち読んでく。

■_ 見逃すところだった

↑の会場で無線LANが使えていなければ気がつかなかったw

Twitter / @Kazuhiro Inaba: boolを定義するには、trueとは何であってfal ...

boolを定義するには、trueとは何であってfalseとは何であるか教えて貰えれば定義できるので、
「それ(t と f)を引数に渡して教えてくれたら定義してやるぜ」 というのが
TRUE=λtf.t FALSE=λtf.f http://bit.ly/emXAaS 。

Twitter / @Kazuhiro Inaba: ペアを定義するには、ペアを作る関数make_pair ...

ペアを定義するには、ペアを作る関数make_pairをく教えてくれれば定義できるので、それ(m)を
引数に貰って PAIR(x, y)=λm. mxy。リストならnilとconsを貰えればわかるから NIL=λnc.n 
CONS(a,d)=λnc.cad。自然数ならゼロと+1を…
Twitter / @Kazuhiro Inaba: 要は 「そのデータ型の値を全部作り出せるようなプリミ ...

要は 「そのデータ型の値を全部作り出せるようなプリミティブ(true, false, nil, cons, 0, 
+1, ... など) を引数として渡したら、それを使って値を実際に作ってくれるようなファクトリ
関数」 のことを、「値」と見なしてλ計算の中で使うスタイル
Twitter / @Kazuhiro Inaba: [1,2,3] というリストは λnc. (c 1 ...

[1,2,3] というリストは λnc. (c 1 (c 2 (c 3 n))) みたいな。
Twitter / @Kazuhiro Inaba: 「CONS(a,d)=λnc.cad」これ嘘だ。λn ...

「CONS(a,d)=λnc.cad」これ嘘だ。λnc.ca(dnc)だな

ありがとうございます。

■_ 例の

気がついたらまたこのネタが。

【超初心者】プログラミング質問スレ【基礎】part3 

598 デフォルトの名無しさん [sage] 2011/01/22(土) 20:46:04 ID: Be: 
 どうして変数は、i を使うんですか。 
 
599 デフォルトの名無しさん [sage] 2011/01/22(土) 20:49:34 ID: Be: 
 おそらく添え字(index)の頭文字だから 
 
600 デフォルトの名無しさん [sage] 2011/01/22(土) 20:52:12 ID: Be: 
 fortranでiが整数になってて、ループやら配列の添字にiを使う慣習ができで、 
 そこから後発の言語に広まったって説も。

601 デフォルトの名無しさん [sage] 2011/01/22(土) 20:55:43 ID: Be:
    integer 

602 デフォルトの名無しさん [sage] 2011/01/22(土) 20:56:55 ID: Be:
    IntegerかIndexのinを添え字にしてたのがやっぱ1文字にしようってことになって
    iとnの間のi,j,k,l,m,nを各種変数に使うことになったとかうんぬん 

603 デフォルトの名無しさん [sage] 2011/01/22(土) 21:25:12 ID: Be:
    俺はi,j,kが何かの言語で宣言しないでも使える変数だったもんで、
    これが定着したとかいう話を何かの本で読んだ。

    あとロマンチックな回答として「プログラムに愛をちりばめて(ry」的な事を考えたが止めた。 

604 デフォルトの名無しさん [sage] 2011/01/22(土) 21:46:55 ID: Be:
    iteration 説 

605 デフォルトの名無しさん [sage] 2011/01/22(土) 21:47:46 ID: Be:
    っていうか数学でも i, j, k って使うじゃん? 

606 デフォルトの名無しさん [sage] 2011/01/22(土) 21:55:18 ID: Be:
    英語でも使うよ? 

607 デフォルトの名無しさん [sage] 2011/01/22(土) 22:19:13 ID: Be:
    >>600 が正解じゃよ 

608 デフォルトの名無しさん [sage] 2011/01/22(土) 22:26:38 ID: Be:
    ソース出せよ 

609 デフォルトの名無しさん [sage] 2011/01/22(土) 22:30:33 ID: Be:
    ぐぐれかす
    http://bit.ly/hKJaQX 

610 デフォルトの名無しさん [sage] 2011/01/22(土) 22:31:38 ID: Be:
    >>608
    ほらよソースだ。7カラムにピシっとそろえた美しい言語。
    http://fortran.hiroshism.com/lesson/lesson1.html 

611 デフォルトの名無しさん [sage] 2011/01/22(土) 22:31:57 ID: Be:
    iをループカウンタに使う慣習はfortranから始まったってのは確かだろうな。 

612 デフォルトの名無しさん [sage] 2011/01/22(土) 22:37:14 ID: Be:
    うん。FORTRANしかコンパイラが無かった時代があったからな。 

613 デフォルトの名無しさん [] 2011/01/22(土) 22:39:48 ID: Be:
    ちなみにiではなくIだ。

609 の提示しているリンクの先は Wikipedia で、しかも「要出典」ついてんだよねー。 FORTRAN I のマニュアルに掲載されていたサンプルプログラムでも 三重ループで I, J, K と使っていたのでプログラミング上の慣習としては まあ 611 で間違いないとは思うのだけど、それがどこからきたのか(編み出されたのか) はわからんのですよね(少なくとも開発者の証言はでてきてないんじゃないかと)。

■_ mawk

libmawk なんてのを作ってる人もいるみたいで。

mawk - pattern scanning and text processing language

Synopsis 

mawk is an interpreter for the AWK Programming Language. 

History 

Mawk was written by Mike Brennan. There has been no maintainer for some time. I have 
adopted it, starting with fixes from the Debian package, and resolving issues which 
the package maintainer did not respond to. 

結局、Michel はなんで mawk 放り出したんだろう。 1.3.3 がリリースされたあたりでちょっとメールのやり取りをしたことがあるんだけど、 次のバージョンがどうこうとか書いてたんだよねえ。 まあ無用の詮索は止めておこう。

で、上記のページにあったリンクから Changelog を見てみたり。



-- $MawkId: CHANGES,v 1.127 2010/06/25 09:43:31 tom Exp $ 
 
Changes by Thomas E Dickey <dickey@invisible-island.net> 
 
20100625 
 + correct translation of octal and hex escapes for system regular  expression library. 
 + modify configure script to support --program-suffix, etc. 
 + add Debian package scripts, for "mawk-cur". 
 + add RPM spec-file. 
 + move release- and patch-level values from version.c to patchlev.h 
 to simplify packaging scripts. 
 
20100618 
 + correct translation of "^{" pattern for system regular expression 
 library (report by Elias Pipping). 
 + fix sentence fragment in README (report by Elias Pipping). 
 
20100507 
 + cleanup gcc warnings for 64-bit platform, e.g., use size_t rather  than unsigned, etc. 
 + fix warnings from clang --analyze 
 + update/improve configure script 
 + modify CF_GCC_VERSION to ignore stderr, e.g., from c89 alias 
 + modify CF_GCC_WARNINGS, moving -W and -Wall into the list to check, 
 since c89 alias for gcc complains about these options. 
 + add --disable-leaks and related options, for testing. 
 + add lint rule to makefile. 
 + add configure-check for ctags to work with pkgsrc. 
 + amend change of array.w, fixes a regression in "delete" (report by 
 Heiner Marxen). 
 
20100419 
 + modify split() to handle embedded nulls in the string to split, e.g., 
 BEGIN{s="a\0b"; print length(s); n = split(s,f,""); print n} 
 (report by Morris Lee). 
 
 + modify array.w to update table pointers in the special case where 
 an array is known to have string-indices, but is later indexed via 
 integers. The problem occurs when the array grows large enough to 
 rehash it, e.g., 
 BEGIN{a["n"];for(i=1;i<1000;++i)printf "%d\n", a[i]; } 
 (report by Morris Lee). 
 
 + increase size of reference-count for strings to unsigned. It was an 
 unsigned short, which prevented using arrays larger than 64k, e.g., 
 BEGIN{for(i = 1; i <= 65550; ++i){if(i >= 65534 && i<= 65537) print i; s[i] = "a"}; delete s;} 
 (report by Morris Lee). 
 
 + add special case for Solaris 10 (and up) to configure check  CF_XOPEN_SOURCE 
 
 + refactored configure check CF_REGEX 
 
20100224 
 + add a configure check for large files (report by Sean Kumar). 
 
 + modify check in collect_RE() to show the actual limit value, e.g., 
 MIN_SPRINTF-2 used for built-in regular expressions. 
 
 + increase MIN_SPRINTF, used as limit on regular-expression size, to 
 match the MAX_SPLIT value, i.e., slightly more than doubling the size 
 (report by Markus Gnam). 
 
 + further modify makefile to build outside the source-tree. 
 
 + modify makefile and mawktest to use relative path again, since the 
 existing script did not work with openSUSE's build (patch by Guido 
 Berhoerster). 
 
 + fix makefile's .c.i rule, which lacked CPP definition. 
 
 + update mawktest.bat script to more/less correspond with mawktest, 
 for Win32 console except where echo command does not handle the 
 required quoting syntax. 
 
 + add vs6.mak, for Visual Studio 6. 
 
 + modify mawktest script to report results from all tests, rather than 
 halting on the first failure. 
 
 + add limit-check after processing match(test, "[^0-9A-Za-z]") to 
 ensure the internal trailing null of the test-string is not mistaken 
 for part of the string, i.e., RSTART, RLENGTH are computed correctly 
 (report by Markus Gnam). 
 
 + modify parsing of -W option to use comma-separated values, e.g., 
 "-Wi,e" for "-Winteractive" and "-Werror". 
 
 + add timestamp to scancode.c, to help manage revisions. 
 
 + improve configure macro CF_XOPEN_SOURCE, making it remove possibly 
 conflicting definitions before adding new ones. 
 
 + update config.guess and config.sub 
 
 > patches by Jan Psota: 
 
 + improve buffering for -Winteractive option. 
 
 + allow multiple single-character flags after -W, e.g., "-Wie" for 
 "-Winteractive" and "-Werror" to permit these to be passed on a 
 "#"-line of a shell script, e.g., 
 #!/usr/bin/mawk -Wie 
 
 > patches by Jonathan Nieder: 
 
 + add new M_SAVE_POS and M_2JC operation codes (states) to the 
 built-in regular expression engine. Use these to reimplement 
 m* (closure), to provide a way to avoid infinite looping on 
 matches against empty strings. This change requires reimplementing 
 the workaround for gawk's noloop1 testcase from 20090726. 
 
 + improve buffer-overflow check for string_buff. 
 
 + fix collect_RE to treat "[^]]" as a character class (meaning "not a 
 closing bracket") but "[^^]]" not as one. This also requires 
 initializing the local "start of character class" variable to NULL 
 rather than the beginning of the string, to avoid an invalid array 
 access when collecting expressions such as "^text". 
 
 + within a character class and not followed by a :, ., or ~, a "[" is 
 just like any other character. This way, you can tell mawk to scan 
 for a literal [ character with "mawk /[[]/", and you can scan for a [ 
 or ] with "mawk /[][]/". Also clean up the relevant loop in 
 do_class() to make it a bit more readable. 
 
 + outside a character class, a "]" is just like any other character. 
 
 + prevent do_class() from scanning past the end, e.g., if the 
 terminating zero byte was escaped. 
 
 + fix regular-expression parsing when a right parenthesis ")" is 
 found without a preceding left parenthesis. 
 
 + fix resetting of position stack when backtracking. 
 
 + modify regular-expression engine to avoid exponential running time 
 for some regular expression matches in which the first match mawk 
 finds extends to the end of the string. This is a new fix for the 
 gawk noloop2 test, added here for regression testing. 
 
20091220 
 + bump version to 1.3.4 
 
(略) 

結構いろいろやってるなあ。

で、見方が良くわからんだけど、1.3.3 からの変更量を図示してるっぽいもの

>

-------------------------------------------------------------------------------- 
 CHANGES | 42 
 INSTALL | 47 
 Makefile.in | 124 ! 
 README | 92 ! 
 array.c | 605 !======= 
 array.h | 51 
 array.w | 1092 !!============= 
 bi_funct.c | 1015 !!!!!!!!!!!==== 
 bi_funct.h | 67 
 bi_vars.c | 92 = 
 bi_vars.h | 59 
 cast.c | 418 !!!!== 
 code.c | 256 !!= 
 code.h | 192 == 
 configure | 2333 !!!!!!!!!!!!!!!!!!!!!!!!!=========== 
 configure.in | 49 
 da.c | 431 !!!!== 
 error.c | 397 !!!!== 
 examples/ct_length.awk | 28 
 examples/decl.awk | 143 == 
 examples/deps.awk | 57 
 examples/eatc.awk | 32 
 examples/gdecl.awk | 136 == 
 examples/hcal | 418 ====== 
 examples/hical | 75 = 
 examples/nocomment.awk | 30 
 examples/primes.awk | 62 
 examples/qsort.awk | 78 = 
 execute.c | 1456 !!!!!!!!!!!!!!!!!===== 
 fcall.c | 442 !!!!= 
 field.c | 686 !!!!!!!== 
 field.h | 105 = 
 files.c | 621 !!!!!!=== 
 files.h | 67 = 
 fin.c | 586 !!!!!!== 
 fin.h | 56 
 fpe_check.c | 263 !!== 
 hash.c | 258 !!= 
 init.c | 388 !!!== 
 init.h | 60 
 jmp.c | 283 !!= 
 jmp.h | 45 
 kw.c | 95 = 
 main.c | 84 = 
 makescan.c | 119 ! 
 man/mawk.1 | 1616 ========================= 
 man/mawk.doc | 1254 -----!!!!!!!!!!!== 
 matherr.c | 277 !=== 
 mawk-1.3.4/MANIFEST | 147 ++ 
 mawk-1.3.4/aclocal.m4 | 1285 ++++++++++++++++++++ 
 mawk-1.3.4/config.guess | 1501 +++++++++++++++++++++++ 
 mawk-1.3.4/config.sub | 1705 ++++++++++++++++++++++++++ 
 mawk-1.3.4/config_h.in | 64 + 
 mawk-1.3.4/install-sh | 294 ++++ 
 mawk-1.3.4/makedeps.sh | 49 
 mawk-1.3.4/man/TODO | 86 + 
 mawk-1.3.4/regexp.c | 12 
 mawk-1.3.4/regexp_system.c | 214 +++ 
 mawk-1.3.4/rexp.c | 231 +++ 
 mawk-1.3.4/rexp.h | 170 ++ 
 mawk-1.3.4/rexp0.c | 800 ++++++++++++ 
 mawk-1.3.4/rexp1.c | 232 +++ 
 mawk-1.3.4/rexp2.c | 348 +++++ 
 mawk-1.3.4/rexp3.c | 433 ++++++ 
 mawk-1.3.4/rexp4.c | 18 
 mawk-1.3.4/rexpdb.c | 92 + 
 mawk-1.3.4/scancode.h | 61 
 mawk-1.3.4/test/full-awk.dat | 3 
 mawk-1.3.4/test/null-rs.awk | 3 
 mawk-1.3.4/test/null-rs.out | 1 
 mawk-1.3.4/test/nulls.out | 22 
 mawk-1.3.4/test/nulls0.awk | 4 
 mawk-1.3.4/test/reg4.awk | 23 
 mawk-1.3.4/test/reg5.awk | 26 
 mawk.h | 177 != 
 memory.c | 101 = 
 memory.h | 50 
 missing.c | 192 !! 
 msdos/dosexec.c | 178 != 
 nstd.h | 102 = 
 parse.c | 2621 !!!!!!!!!!============================== 
 parse.y | 1373 !!!!!================ 
 patchlev.h | 5 
 print.c | 580 !!!!!!== 
 re_cmpl.c | 415 !!!!= 
 regexp.h | 32 
 repl.h | 37 
 scan.c | 1080 !!!!!!!!!!!!==== 
 scan.h | 103 
 sizes.h | 104 = 
 split.c | 335 !!!= 
 symtype.h | 189 != 
 test/fpe_test | 103 = 
 test/mawktest | 62 
 test/mawktest.bat | 51 
 test/reg-awk.out | 3 
 types.h | 107 = 
 version.c | 144 = 
 zmalloc.c | 195 != 
 zmalloc.h | 48 
 100 files changed, 7824 insertions(+), 869 deletions(-), 11604 modifications(!), 13096 unchanged lines(=) 

こいつの正規表現エンジンはなかなか面白い実装だったんだけど、 マルチバイト文字なんて露ほども考えてないものだったんだよなあ。 UTF-8限定にしたら楽できるかな?

■_

2011年01月21日

■_

なんのかんので土曜は色々予定が入ってるなあ。

まだ途中までしか読んでないけど面白い。

野茂英雄―日米の野球をどう変えたか (PHP新書)
野茂英雄―日米の野球をどう変えたか (PHP新書)

■_ λ

本題はどうでもよく(笑)

Conditional statements, the lambda calculus and early/late binding « LShift Ltd.

Conditional statements, the lambda calculus and early/late binding 
 
Soon after I started learning Smalltalk, I found my brain broken. Smalltalk doesn't 
have control structures. No ifs, no whiles, no for loops. All these structures are 
instead patterns of message passing [1]. 
 
Conditionals in Smalltalk work like this: the class Boolean has two subclasses, True 
and False. Each has a well-known instance, true and false, respectively [2]. 
 
The equivalent of C's 
 
  if (condition) { 
       one_func(); 
  } else { 
      other_func(); 
  } 
 
is 
 
  condition 
     ifTrue: [ self oneMethod ] 
     ifFalse: [ self anotherMethod ] 

(略)

I grabbed Wikipedia (font of all true information, of course) and looked at the lambda 
calculus. You can implement conditionals like this, in the untyped lambda calculus: 
 
 TRUE = λxy. x 
 FALSE = λxy. y 
 IFTHENELSE = λcxy. c x y 

これは何度見ても理屈が良くわからん○| ̄|_ > λxy. x とか。

TAPL読書会でやったはずじゃないのかよ…

■_ '-'

A Word for the Slow « Just Rakudo It
 
The key organizational piece for my solution is the Ordering class. (BTW, I didn't 
like that name at all, it's probably my least favorite part of my solution. My theory 
is Masak was too awestruck by my inefficiency to quibble about the name.) I was 
striking about for how to represent a series of matrix multiplications, and hit on the 
idea of using a very simple stack-based language to do it. The language has two 
operations: an Int represents putting the matrix with that index on the stack. The 
string "*" represents popping the top two matrices on the stack, multiplying 
them, and pushing the result back on the stack. Here's the code for making that 
happen while tracking the total number of multiplications: 

01 method calculate-multiplications(@matrices) { 
02     my @stack; 
03     my $total-multiplications = 0; 
04     for @.ops { 
05         when "*" { 
06             my $a = @stack.pop; 
07             my $b = @stack.pop; 
08             my ($multiplications, $matrix) = multiply($a, $b); 
09             $total-multiplications += $multiplications; 
10             @stack.push($matrix); 
11         } 
12         when Int { 
13             @stack.push(@matrices[$_]); 
14         } 
15     } 
16 
17     $total-multiplications; 
18 } 
 
I'm an old Forth programmer from way back, and I can't begin to say how much I love 
how easy p6 makes it to implement a simple stack machine! 

本文の内容とかはどうでも良くて(笑)、 calculate-multiplications(@matrices) $total-multiplications これ、Unicode のハイフン記号でなく '-' なのかな? 使えるのは嬉しいけど(アンダースコアはシフトキー押さないといかん :)、 lexer が面倒…でもないか? Perl は sigils あるしなあ。

■_ Mpdula-2 FAQ

いくつかピックアップ。

Modula-2 FAQ

 
1.3 How do you pronounce Herr Wirth's name? 
 
A. It is incorrect to call him by his value (worth.) Instead his name is veart. 
 
 
1.5 How does Modula-2 fit into the language zoo? 
 
A. It is a descendent of Pascal and Modula, and one predecessor of Modula-2+, 
Modula-2*, Modula-3, Oberon, Oberon-2, and various object oriented versions of these. 
The latter languages are not replacements for Modula-2, merely later notations in the 
same family, having strengths and weaknesses of their own. Modula-2 is sometimes 
classified with Ada and C++ as the trio of modern languages in view of their 
expressive power. Modula-2 is smaller and more readable than either. 
 
1.6 What are the differences between Modula-2 and Standard Pascal? 
 
A. Modula-2 has separately compiled library modules, and makes much less use of blocks 
(begin...) than Standard Pascal. Identifiers are case sensitive; there is no goto 
label; and I/O is in libraries rather than built in. The IF statement is more 
versatile; and there are facilities for concurrent programming via coroutines. 
Extended Pascals may have some of these features. 
 
1.8 What difference is there between classical and ISO Modula-2? 
 
A. ISO Modula-2 has resolved most of the ambiguities in classical Modula-2. It adds 
the data type COMPLEX and LONGCOMPLEX, exceptions, module termination (FINALLY clause) 
and a complete standard I/O library. There are numerous minor differences and 
clarifications. 

1.9 What is (was) Turbo Modula-2 

A. Borland prepared CP/M versions of Modula-2 and sold them for a time in Europe (also 
in North America via a distributer.) One of these versions later migrated to become 
TopSpeed Modula-2. 

1.10 What is (was) Top Speed Modula-2 
 
See also 1.9. Eventually, Top Speed merged with Clarion, a maker of database products, 
who used Modula-2 as their DB language, and for a time sold Top Speed separately. 
Later still, this became SoftVelocity, but the Modula-2 compiler has vanished. A 
fuller history is available at http://www.attryde.com/clarion/. 

4.11 Where can I get the C code of a Modula-2 compiler? 

A. Most Modula-2 compilers are written in Modula-2. Indeed, though there are 
exceptions, and there are usually good reasons for the exceptions (cross compiling, 
fitting into an existing framework), most compilers for a given language are written 
in that language. 

ああ、Turbo Mpdula-2…

■_

■_

明日(22日)、13時までに神保町行けるかしらん(^^;

■_


一つ前へ 2011年1月(中旬)
一つ後へ 2011年2月(上旬)

ホームへ


リンクはご自由にどうぞ

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