http://www.kt.rim.or.jp/~kbk/zakkicho/index.html - 11/21/09 07:05:07 - 10/07/08 13:59:44
2009年11月03日
・日本シリーズ ダルビッシュ登板について東スポで言及している記事が。 メジャースカウトは軒並み「なんてことするんだ」的な反応だったらしい(笑) まあそうだろうねえ。 んで、この先の展開によってはもう一回登板があるかもというのはどうなんだろう。 いくらなんでも無理だろういろいろと。 実際、投手陣は反対しているらしいし。
■_ \s?
知恵袋から。
egrepの使い方を教えてください。 - Yahoo!知恵袋 egrepの使い方を教えてください。 /etc/servicesから「22/tcp」、「53/tcp」の行を抽出する場合、下記のコマンドを 実行すると抽出されます。 「egrep '\s(22|53)/tcp' /etc/services」 しかし、「22/tcp」だけ抽出しようと下記コマンドを実行すると、何も抽出されません。 「egrep '\s(22)/tcp' /etc/services」 「egrep '\s22/tcp' /etc/services」 なぜ抽出されないのでしょうか?egrep '\<22/tcp' /etc/services これでいけますよ。 詳しくはmanを読むといいですが、抜粋すると以下の部分です。 The symbols \< and \> respectively match the empty string at the beginning and end of a word. 日本語で同じような解説を書いてあるページがあったのでそのサイトより抜粋 \< \m,[[:<:]] “単語”の先頭にマッチします。たとえば \<away は awayにマッチしますが、faraway にはマッチしません。 <補足> \sについて議論されてるようですが >GNU grep 2.5以降ではPCREを使った Perl互換の正規表現指定ができます(PCREのリンクを有効にした場合)。 と書いてあるサイトを発見しました。 とはいえ、ロケールに左右される方法では確実とはいえませんので Perlの正規表現は利用しない方が良いです。 (実際こちらの環境でもLANG=Cで\sを試したところ使えませんでした) \<を利用してはいかがですか?egrep '\s(22|)/tcp' /etc/services なら 22/tcp の行だけ抽出されますね。 でも、これってスマートじゃないですね。 >なぜ抽出されないのでしょうか? う〜〜ん.... もっとスマートな回答を待ちましょう! [追記] xinusun さん egrep '\s(22|53)/tcp' /etc/services では 22/tcp と 53/tcp の行だけが抽出されますよ。 [追記2] locale は ja_JP.UTF-8 で確認しています。 質問者が知りたい事(=私が知りたい事)は 「22/tcp の行だけを抽出するにはどうすればよいか?」 だと思います。 [追記3] kuma_san_2009 さん > egrep '\<22/tcp' /etc/services なるほど、空白文字でマッチさせるのではなく、単語の先頭でマッチさせるのですね。 これだとロケールにも左右されませんね。 とっても勉強になりました。 m(_._)m 早速「知恵コレクション」に追加させていただきます。 [追記4] egrep でなく grep でも同じ結果が得られますね。 http://www.kt.rim.or.jp/~kbk/regex/regex.htmlxinusunさん \s について認識違いをされていませんか? \s で空白文字とマッチさせたいのだと推測しますが、egrep では \s を空白文字の 表現としてサポートしていません。 (perl などではサポートしていますが...) egrep では \s は s と等価になってしまいます。 > /etc/servicesから「22/tcp」、「53/tcp」の行を抽出する場合、下記のコマンドを > 実行すると抽出されます。 >「egrep '\s(22|53)/tcp' /etc/services」 ですから、そもそも上記ではマッチしないと思いますが、本当にマッチしましたか? egrep '[ ■](22|53)/tcp' /etc/services などとすればよいと思います。 なお、上記において ■ はタブを表します。 回答ではタブをそのまま書いてもそのままタブとして反映されないので、■ をタブの代替として使っています。 実際に実行する際は、■ をタブに変更して下さい。 【dolphin960413 さんへの補足】 ロケールは何で試されていますか? 私は C ロケール(LANG=C)で試していたのですが、ja_JP.UTF-8 などだとマッチしてしまうようですね。 ですがこれは正しい動作なのでしょうか? 私には不具合のような気がします。(ちなみに Solaris 10 + GNU egrep の環境では ja_JP.UTF-8 でもマッチしません。) egrep のマニュアルページなどを確認すればお分かりになると思いますが、少なくとも egrep では \s は空白文字ではありませんよね。 【kuma_san_2009さん への補足というか蛇足】 確かに grep -P とすれば Perl の正規表現が使えますが、man には以下の通り "highly experimental" の記述がありますね。 ちなみにロケールにより挙動が変わるのは egrep(grep -E) の時で、grep -P ではロケールによ らず正常に動作するようですね。 -P, --perl-regexp Interpret PATTERN as a Perl regular expression. This is highly experimental and grep -P may warn of unimplemented features.PCREをリンクした場合云々て書いてあるサイトって、わしんとこか?w
んで、GNU 拡張で \s てのはなくはないのだけど、それは Emacs で使われるもので Perlのとは意味も違ったりする。だからそもそも質問にあるようなマッチングするのは 使っているのが GNU grep であるなら考えられない。 って、OSとかもなんにも書いてないじゃないか。 みんなGNU grep だって決め打ちすぎw
そういや -P 指定時って C locale でないと期待通りの動作しないような気がする。 そもそも PCRE自体が ASCII (ISO-8859-1か?) か UTF-8 しか受け付けないし、 UTF-8のときはなんかごちゃごちゃお約束があったような覚えがあるけど、 GNU grep の側でそれをケアしてなかったような… 面倒くさいので確かめないけどな(笑)
■_ C1X Standard
gets がなくなる?
C/C++ Café | C Standard : Tags : alignment C Standard The View (or trip report) from the Oct 2009 C Standard meeting Posted by Michael_Wong Nov 2, 2009 This is the meeting that closes on all new features for the upcoming C1X Standard (with only a few minor known exceptions) In this meeting, we processed a number of key issues. We incorporated a few additional details to the memory model and concurrency proposals taken from C++ Standardization. We moved zero-initialization for thread locals from 5.1.2p1 to integrate with 6.7.8p10 One proposal removed gets() from the standard. This has been a problematic function, and was made obsolete in TC3. The function gets() has been problematic because of uncertain newline removal. The answer for a long time is to use fgets() instead. We reviewed whether C wishes to support a general syntax for attributes similar to C++. This was rejected as most members were uncomfortable with the need and the consequences. Instead, C will adapt keywords prefixed with a single underscore for future attributes. For example, the alignment proposal will use _Align. Personally, I feel this will cause C more problems in the future as attributes proliferates. But I do not think it precludes future adaption of a generalized system, if the need becomes serious. although right now the consensus is that C does not want general system for attributes. I also pitched the concept of a common vectorized type for C based on OpenCL. There was general enthusiasm for the feature as many felt the need to drive for future parallelization support based on many existing implementations of vector extensions. However, due to C1X being on a schedule for completion of features, and the relative size of this proposal, the members felt that this proposal need time to develop. Furthermore, there was interest in maintaining close liaison with OpenCL to ensure we do not create dialects of OpenCL if we were to pick subsets. In the end, the meeting closed with great belief that we are on track to have a feature completed draft by the next meeting in April, 2010. This puts C on a very promising track to finish on time.
general syntax for attributes similar to C++ってなんだろう?でもまあ標準規格から gets がなくなったとしても結構使われ続けたりするんだろうなあ。 そいや、strlcpy/strlcat 的なものの追加はないんだろうか?
「トランポリン」を使うと再帰呼び出しするような関数の実装でいいことあるよ という話らしいのだけど、ここに書かれている例ではあまりありがたみは感じないなあ。
Recursion Using Trampoline Functions Recursion Using Trampoline Functions Trampoline function is a general term used to describe an additional level of indirection between the calling code and the called code. For example, a trampoline can be used to intercept calls to a function and supply additional functionality that was not present on the original function (see this Microsoft research project [2] to understand what is possible). *トランポリン使わない版 int fact(int x, int total) { if (x <= 1) return total; return fact(x-1, total*x); } int main() { printf("result is %d\n", fact(10, 1)); return 0; } The problem with this version is that you are using the function stack to maintain the intermediate results. While this is not really a problem here (because the size of the integer is more of a limitation than the size of the stack), it can be a real concern in other recursive implementations. →スタックに積む情報が多いから、それが問題になる場合があるんじゃね? Let us see what we can do using a trampoline function. That is, instead of calling the function itself, we call a pointer to a function that is supposed to do what it needs to do, and then return a pointer to a place where we need to go next: →「トランポリン」を使ってこう書いてみると #include <stdlib.h> #include <stdio.h> typedef void * (*Func)(int *x, int *total); void *fact0(int *x, int *total) { return NULL; } void *fact(int *x, int *total) { if (*x <= 1) return fact0; *total *= *x; *x = *x-1; printf("total %d, x: %d\n", *total, *x); return fact; } int main() { int res=1, n = 10; Func f = fact; while (f != NULL) { f = (Func)f(&n, &res); } printf("result is %d\n", res); return 0; } This also works, and now there is no problem with the stack size: at each time, the stack holds only the context for the function that is being called. It is always possible to do something like this in a tail recursive function, because we don't need to store return information for the last call. →スタックの消費量が抑えられる。 In fact, as mentioned by Knuth [1], the method described above can be used to implement any algorithm. This is exactly the direction taken when implementing some interpreters to scheme. The basic idea is to use continuations to store control structure information, so that one never needs to return from a function. However, as stack size is limited in languages such as C, the tactic explained above is used, so one can work with trampoline functions instead of continuations. Tricky but useful when implementing functional languages. For a similar example in Python, see [3]. [1] Structured Programming With Goto Statements, D.E. Knuth, A.C.M. Computing Surveys, Vol. 6, pp. 261-301. [2] http://research.microsoft.com/apps/pubs/default.aspx?id=68568 [3] http://mail.python.org/pipermail/tutor/2004-August/031553.html Copyright © Carlos Oliveira · All rights reserved.
This is exactly the direction taken when implementing some interpreters to scheme.へー。久しぶりに PLNewsからネタ拾い
Duby 0.0.1 Released @ PLNews: Programming Language News Nov. 02, 2009 Duby 0.0.1 Released Duby 0.0.1 has been released. It is a programming language with a Ruby-inspired syntax, with an implementation generating JVM bytecode or Java source files. This is the initial release.Ruby に影響を受けたと? んで、言語の紹介ページを見ると
The Duby Programming Language — Project Kenai Duby is a highly customizable programming language (or a structured assembly language) featuring type inference and a heavily Ruby-inspired syntax, while allowing both the inference engine and the compiler backends to be entirely customizable for any platform or type system. Duby currently includes a typer/compiler backend for the JVM.customizable?
R 2.10.0 Released @ PLNews: Programming Language News Nov. 02, 2009 R 2.10.0 Released 2009-11-02 20:18:18 R 2.10.0 has been released. R is a language and environment for statistical computing and graphics. This release includes: a new HTML-based dynamic help system, new functions, installation updates, regex and compression changes, bug fixes, and other changes.え? 2.10 ってことはそれなりに大きなバージョンアップ? 2.9.3 とどのくらい違うんだろう? あとでチェックしとこ。 http://cran.r-project.org/src/base/NEWS
Fortress Blog Announced @ PLNews: Programming Language News Nov. 02, 2009 Fortress Blog Announced 2009-11-02 20:15:45 Languages :: Fortress, Websites Guy Steele has announced the creation of a blog at the ProjectFortress Community site.[Language] Announcing a Fortress blog We're going to try to experiment of cranking up a blog at the ProjectFortress community website. I will try to make sure a new article is posted at least once a week to keep everyone up to date on technical discussions and decisions, the status of the compiler implementation, and various language features of interest. My first post discusses the new wiki markup for tables for use in Fortress comments, and my second post discusses some changes to the typing rules for conditional expressions that will help them to interact better with coercion. I also plan to report soon on the status of our efforts to construct a Fortress compiler. Visit http://projectfortress.sun.com/Projects/Community/blog or click on the "Blog" item at the right-hand end of the menu bar on the main Wiki page. --Guy Steele P.S. I tried to announce this a week ago and found that we had problems with these mailing lists. They should now be up and running again.へー。
- Twitter / naoya t: 長門型プログラミングの「師匠」 @natsutan ...
- Twitter / yukishita: Parser Combinatorが分かりにくいとい ...
- App Storeエフェクト―iPhoneアプリのどん底に向けての競争 : Gizmodo Japan(ギズモード・ジャパン), ガジェット情報満載ブログ
- 渋日記: 1日~1週間のでOSSに貢献する方法
- 『化物語』のラストエピソードが度重なる延期を経てついにWeb配信開始:【2ch】ニュー速VIPブログ(`・ω・´)
- 告白を断るときの正しいステータスコードの返しかた - As Sloth As Possible
- 急進的な改革は危なっかしい
- 愛が足りないから - 猫的怠惰Days
TOYOTA wayと呼ばれるメソッドは、従業員一人一人に対して負荷を与えるシステムだ。 カイゼンしろというのは簡単だが「で、カイゼンすると何かいいことがあるのですか? それを行うとどのようなメリットを与えてくれるのですか?」ということに対して明確に回答できない、 あるいは暗黙の回答が提示されていないところでは決して成功しない。- いいとこ取りの「リーン・シックスシグマ」は泣ける? - 編集の現場から:ITpro
- ジュンク堂書店池袋本店 トークセッション情報中と外から見たRails ■2009年 12月3日(木) 19:00 ~
- Twitter / しかのつかさ: インフルエンザは、個人レベルではほとんどたいしたこと ...
- C言語で使用する変数名の最大文字数とはいくらまででしょうか? - Yahoo!知恵袋
- HP作成業者に作成代行の見積もりを HPから依頼すると、 - Yahoo!知恵袋
- 汎用 COBOLで 帳票作成のサンプルプログラムはありませんか? - Yahoo!知恵袋
- var/タワゴト(2009-11-03)
フリーセルって写経のように落ち着くね。最近やってないなあ。Windows 95の頃は猿のようにやってたけどw- 「使ってもらえる」UIが生産性を向上する――iPhone法人利用のメリットとは(前編)(+D Mobile) - Yahoo!ニュース
- クレイ・シャーキー曰く「情報洪水などない。それはフィルタリングの失敗だ」:シロクマ日報:ITmedia オルタナティブ・ブログ
- Twitter / _ko1: http://www.cs.umd.edu/~jfo ...
- 技術系の翻訳をするときに気をつけてること - atsuoishimotoの日記
- ITの企画 -OKWave
IT部門に居るのですが、この不景気でお金がありません。低コストで経営に大きく寄与するソリューションを探しています。- がんばれ長妻たん!:アルファルファモザイク - 2ちゃんねるスレッドまとめブログ
- スイスの駅で見た時計カコイイ!:アルファルファモザイク - 2ちゃんねるスレッドまとめブログ
- Twitter / Mikio Yoshida: コードは通常は人に見られないものだけど、美意識を持っ ...
- Getting Started with Agda アグダを始めよう - にわとり小屋でのプログラミング日記
- お部屋1975/図書館の中では見えないこと 5 | ポット出版
- 知識の伝達は難しい:柴田 芳樹 (Yoshiki Shibata):So-net blog
文書にして配布するだけで、知識が共有化されて、組織全体の底上げができるというのは、私自身は昔から幻想だと思っています。- クレイ・シャーキー曰く「情報洪水などない。それはフィルタリングの失敗だ」:シロクマ日報:ITmedia オルタナティブ・ブログ
- サンコー、4.3型液晶で6,980円のメディアプレーヤー -AV Watch
割と自分が欲しいと思ってたのに近い。- http://www.kmonos.net/pub/Presen/PLDIr3.pdf