ときどきの雑記帖 再起編


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





ついったのわたしのTLで結構出てきました Island Life - 知的なツール、努力の方法 僕は自分が思っていたほどは頭がよくなかった - しのごの録 wrong, rogue and booklog - I moved into one of the dorms at MIT thinking I...



Haskell に関する本について。

Modern reall-world Haskell? : haskell

how does one learn "intermediate" Haskell these days?

Quickly sketching out some levels:

    Level 1: Learn You a Haskell For Great Good / A Gentle Introduction to Haskell
    Level 2: Real World Haskell
    Level 3: Chase down all the classic papers (Awkward Squad, ByteString, etc), methodically
             read Haddock for everything in Prelude and Platform.

I am missing a book/compendium/tour-guide/directory of Level 3. A "RWH Part II", or
"Advanced RWH". The content may exist around the web, but it's not indexed in one place.

For example, I noticed that "text" is replacing ByteString when the actual use
case is really text. I sort of picked it up from bos's Reddit comments on the Platform
"consensus", getting curious about Unicode, and checking out his blog. There I
discovered aeson (for JSON) and a bunch of practical stuff he made as part of MailRank.
(Including mysql-simple. But not postgresql. But I did catch postgresql-simple on Reddit recently....)

And then there are enumerators and conduits (a successor?), which I heard nothing about last
time I played with Haskell (it's been a while), and now I may have skipped over the whole
enumerator generation (or maybe not, I don't know)

How does one get a handle on modern practical Haskell?

One more note:

Real World Haskell is a blessing and a curse. Bryan O'Sullivan and the team taught 
everyone to use ByteString for text processing and Parsec for parsing, and then 
promptly set off to create Text for (text processing), and Attoparsec for parsing.

Maybe we just need to convince Bryan to update RWH...

© 2012 reddit inc. All rights reserved.


For to, in, index | Diacho というページになぜかたどり着いて。

Diacho Programming Language | Diacho

Diacho Programming Language

Posted on December 6, 2011

Diacho is a statically typed programming language designed from the ground up with 
three goals in mind. The first goal is to be as high performing as possible. The 
second is being as powerful as possible (in terms of being able to code for hardware 
controlling padding, bits, alignment, etc). The third is being as easy to write for as 
possible. Diacho is meant to be a language any programmer can use whenever it is 
systems, server, native or a web application.

Diacho は三つの目標を念頭に設計された静的に型付けを行う言語です。
Diacho は、すべてのプログラマーが

Because of Diacho goals Diacho is a complex programming language with more than 
90keywords and more than 70 operators. However because of goal #3 most of the time you 
do not need to know all syntax and keywords. Diacho is a language meant for real 
programmers and is not meant to be used by non programmers.

Diacho はその目標のために、
Diacho は90を超える数のの予約語と70を超える数の演算子を持った複雑なプログラミング言語です。
しかし目標その3 があるので、ほとんどの場合はすべて構文や予約語を知る必要はありません。
Diacho は本物のプログラマーのためのものであることを目指し、

For the next few months this blog will be update 3 times a week. Everything is subject 
to change and may be removed outright.

All post will generally be in three categories. Core will be about implicit behavior 
or rules. There will be some mention of design. Existing-But-Different will be about 
keywords or features that you likely seen in a language but with a change to them. The 
last common category will be new-features. new-features will be features unique to 
this language or occasionally features not widely known (sometimes we hear about a 
feature existing in a language after we design or implement it into diacho).



twitter 経由で→を知り 最初の PC - in saecula saeculorum こういう本があったと知る→ 電子計算機の誕生 …中公新書273:高橋秀俊(古書・古本) 日本の古本屋:書籍検索結果詳細 んーむ。さすがに図書館に行かないとなさそう。

■_ Fork Core!


Fork Core! | ocaml.janestreet.com

Fork Core!

Sat, 2012/01/07 - 2:28pm — yminsky

We've now put our collection of open-source libraries out on bitbucket. You can find 
and browse the code here.

By putting the code on bitbucket, we hope to make it easier for us to work together 
with other people in the OCaml community. We're just starting (I just started telling 
people that we're ready to accept patches a few days ago), and we already have some 
improvements coming in.

コードを bitbucket に置くことで、わたしたちは OCaml コミュニティのほかの人たちとの

We're still working out how the relationship with external contributors is going to 
work, but I'm very hopeful that this will hlep make Core a foundation suitable for 
lots of people outside of Jane Street to use for building their own applications.

どのように外部の contributor たちと関係を結ぶかについてはまだ作業中です。
しかし、Jane Street の外部にいる多くの人たちにとって、
foundation suitable な Core にする一助になるだろうと大いに期待しているのです。

If you're interested in contributing, join us on the mailing list.

■_ ネタ

~みなもと太郎「風雲児たち」茶屋 其の参拾伍~ 

525 名無しんぼ@お腹いっぱい [sage] 2012/01/09(月) 01:30:38.62 ID:gs1fkUvYP Be:

■_ Pythonic way of opening more than one file at a time


Pythonic way of opening more than one file at a time | Omar Abo-Namous

Pythonic way of opening more than one file at a time
Posted on January 8, 2012

Some hours ago, someone asked on StackExchange about a more pythonic way to represent 
the following code:

数時間前に StackExchange で以下のコードをより pythonic に記述する方法を尋ねている人がいました

    with open(read_csv, 'r') as read_file:
        with open(write_csv, 'r') as write_file:
            reader = csv.reader(read_file)
            writer = csv.writer(write_file)
            for row in reader:
                #Do some stuff to manipulate the fields from read_file and th

Unfortunately, the user deleted his question, before i could post my suggestion. The 
only evidence of the question remaining is this tweet from PythonQuestions. I'm 
posting my extended answer here for future reference and to see, if someone more 
versed in python might correct me.


Major update

Please have a look at the comments section below and some of the corrections posted 
there. Some suggested the use of contextlib, which is a part of the standard library i 
didn't know about yet.. Also, it seems python >2.7 can handle more than one context 
at a time so that my "solution" isn't really needed.

My try

Starting off, i do not think that the syntax used is too unpythonic. If it is only 
used once or twice, i wouldn't change anything about it, but if someone likes to open 
more than one file within a single with-statement often, then writing a proxy class 
that adheres to the with-statements syntax might be useful. For opening two files it 
would look like this:

最初に、わたしは質問にあったあの構文がそれほど unpythonic であるとは思わないのです。
しかし、誰かがひとつの with 文の中で複数のファイルをオープンすることを頻繁にしようと
いうのなら、with 文の構文をより便利にするであろう proxy クラスを書きます。

    class openTwoFiles():
        def __init__(self, file1, file2):
            self.fn1 = file1
            self.fn2 = file2
        def __enter__(self):
            self.f1 = open(self.fn1,'r')
            self.f2 = open(self.fn2,'r')
            return (self.f1, self.f2)
        def __exit__(self, type, value, traceback):

The class openTwoFiles implements the two basic methods __enter__ and __exit__ which 
the with-statement needs to execute. Using this class might look like this:

この openTwoFiles クラスでは __enter__ と __exit__ という
with 文がその実行に必要とする二つの基本的なメソッドを実装しています。

    with openTwoFiles('test.txt','test2.txt') as (f1,f2):
        print f1
        print f2

Of course for the specific code in question the implementation of the csv-class and an 
iterator over the reader might also help, but i'm sticking with the general case, in 
which the opening of the files suffices. The class openTwoFiles might be extended to 
open a arbitrary number of files with custom flags:

    class openFiles():
        def __init__(self, files, flags):
            if isinstance(files,basestring):
                files = [files]
            if isinstance(flags,basestring):
                flags = [flags]
            assert len(flags)==len(files)
            self.files = files
            self.flags = flags
        def __enter__(self):
            self.fhs = []
            for f, fl in zip(self.files, self.flags):
            return self.fhs
        def __exit__(self, type, value, traceback):
            for f in self.fhs:
    with openFiles(['test.txt','test2.txt'], ['r','r']) as ll:
        print ll

    Jean-Paul Calderone on January 8, 2012 at 6:36 pm said:

    Careful. Your context manager is worse than the original version that uses a nested
    with statement. The original version will be sure to close the first file if there is
    an exception opening the second file. Your version will not do this, though: 
    it will raise an exception out of __enter__ and __exit__ will never be called, leaving 
    the first file open until the garbage collector (or reference counting) deals with it.

    Dan Crosta on January 8, 2012 at 6:47 pm said:

    I suspect it'd be more Pythonic (although this is up to some debate) and would lead to
    a simpler implementation if the context manager took *args in its __init__, where *args
    was a tuple of tuples, and where each tuple was (filename, mode) or optionally just
    (filename, ) — thus, each tuple in *args can be passed directly to file() or open().
    In other words — https://gist.github.com/1578946

    Dag on January 8, 2012 at 6:51 pm said:

    with open(‘file1′) as f1, open(‘file2′) as f2:

    For older versions of Python there's contextlib.nested.

    Madjar on January 8, 2012 at 7:18 pm said:

    This could be written as

    with open(read_csv, ‘r') as read_file, open(write_csv, ‘r') as write_file:

    in python 2.7 and python 3, and as

    with contextlib.nested(open(read_csv, ‘r'), open(write_csv, ‘r')) as read_file, write_file:

    in previous versions.

    Sybren on January 8, 2012 at 7:37 pm said:

    This seems to work just fine when everything is working fine. However, what happens
    when you try to open three files, and the second one can't be opened? You'll be left
    with an inconsistent state.

    leavejes on January 8, 2012 at 7:49 pm said:

    I think that in new version of python this is also possible:

    with open(read_csv, ‘r') as read_file, open(write_csv, ‘w') as write_file:

    Jaime on January 8, 2012 at 7:58 pm said:

    I python 2.7 and later, is possible to do this:

    with open(‘file1′) as file1, open(‘file2′) as file2:
    # Read file1 and write in file2

    qb on January 8, 2012 at 8:17 pm said:

    python 2.7 and 3.2.

    with open(‘one.file') as file_one, open(‘second.file') as file_second:

    fungusakafungus on January 8, 2012 at 9:24 pm said:

    Maybe contextlib.nested could be of use?

    from contextlib import nested
    with nested(open(‘file1′), open(‘file2′)) as (f1, f2):

    Paul Giannaros on January 8, 2012 at 10:09 pm said:

    I'd prefer more generic behaviour for this so that you could do e.g.:

    with opens(‘/tmp/foo.py', (‘/tmp/bar.py', ‘w')) as (f1, f2):

    Something like the following would do the trick:

    import contextlib

    def opens(*fnames):
      fs = []
      for x in fnames:
        if not isinstance(x, tuple):
          x = (x, ‘r')
            yield fs
            for f in fs:

    masklinn on January 8, 2012 at 10:51 pm said:

    There are two major issues with your implementation:

    1. If an error happens while closing a file, all next files will be left open
    2. If opening one of the file fails, all files previously opened will be left open

    You should also close the files in the inverse order than the one you opened them in,
    but that's a minor issue.

    Overall, the original code should be left as-is when using Python 2.5 or 2.6. For 
    Python 2.7-only code or Python 3 code, `with` can be used with multiple managers out 
    of the box:

    with open(path1, ‘r') as file1, open(path2, ‘r') as file2:
    # stuff.

    See examples at the bottom of the “with statement”
    section: http://docs.python.org/reference/compound_stmts.html#with

    joaquin on January 8, 2012 at 11:24 pm said:

    you can also go to python 32 context managers:

    with open(‘in.txt') as infile, open(‘out.txt', ‘w') as outfile:

    Michael Hunter on January 8, 2012 at 11:28 pm said:

    This seems a long way to go to just (works in 2.7):

    with open(‘file1′) as f,\
    open(‘file2) as g:

    Leonhard on January 8, 2012 at 11:45 pm said:

    In python 2.7 you can open two files in the same with statement.

    with open(x) as u, open(y) as w:



map_between をやってみる -slice使ったっていいじゃない編- - yanolabの日記


スレ立てるまでもない質問はここで 115匹目

980 デフォルトの名無しさん [sage] 2012/01/10(火) 00:06:55.81 ID: Be:

    [ABC]  と記述すれば、A、B、C、のいずれかになりますよね?


    [^(そば)]  こうすることで、  そば  を除くすべてになるのでしょうか。 

981 デフォルトの名無しさん [] 2012/01/10(火) 00:12:24.62 ID: Be:

982 デフォルトの名無しさん [sage] 2012/01/10(火) 00:13:45.78 ID: Be:






prog21: A Programming Idiom You've Never Heard Ofprog21: Follow-up to "A Programming Idiom You've Never Heard Of"

↑が元で結構盛り上がる→ A Programming Idiom You've Never Heard Of : programming Clarifying follow-up to "A Programming Idiom You've Never Heard Of" : programming

prog21: A Programming Idiom You've Never Heard Of

A Programming Idiom You've Never Heard Of

Here are some sequences of events:

    Take the rake out of the shed, use it to pile up the leaves in the backyard, then put
    the rake back in the shed.

    Fly to Seattle, see the sights, then fly home.

    Put the key in the door, open it, then take the key out of the door.
    #「鍵穴」にしちゃまずいかなあ> in the door/of the door

    Wake-up your phone, check the time, then put it back to sleep.

See the pattern? You do something, then do something else, then you undo the first thing. Or
more accurately, the last step is the inverse of the first. Once you're aware of this pattern,
you'll see it everywhere. Pick up the cup, take a sip of coffee, put the cup down. And it's
all over the place in code, too:

パターンに気がつきましたか? 何かをして、それから別の何かをして、さらに最初にやったことを undo
するというものです。より正確に言えば、最後のステップは最初のものの inverse です。

    Open a file, read the contents, close the file.

    Allocate a block of memory, use it for something, free it.

    Load the contents of a memory address into a register, modify it, store it back in memory.

While this is easy to explain and give examples of, it's not simple to implement. All we
want is an operation that looks like idiom(Function1, Function2), so we could write the
"open a file..." example above as idiom(Open, Read). The catch is that there needs to
be a programmatic way to determine that the inverse of "open" is "close." Is
there a programming languages where functions have inverses?

わたしたちが必要としている操作は idiom(Function1, Function2) のようなものですから、
"open a file..." の例は idiom(Open, Read) のように書けます。
ポイントとなるのは、"open" の inverse が "close."
そういった inverses を持つ関数があるようなプログラミング言語はあるんでしょうか?

Surprisingly, yes: J. And this idiom I keep talking about is even a built-in function in J,
called under. In English, and not J's terse syntax, the open file example is stated as
"read under open."

Surprisingly, yes:
J がそれです。そしてわたしがこれまでお話ししてきたイディオムは J では組み込みの関数であり、
under と呼ばれています。
英語 (and not J's terse syntax) では、ファイルオープンの例は
"read under open." のように state されます。

One non-obvious use of "under" in J is to compute the magnitude of a vector.
Magnitude is an easy algorithm: square each component, sum them up, then take the square
root of the result. Hmmm...the third step is the inverse of the first. Sum under square.
Or in actual J code:

  mag =: +/ &.: *:

+/ is "sum." The ampersand, period, colon sequence is "under." And *: is "square."

ここで +/ は「加算」です。そして、アンパサンド、ピリオド、コロンという
シーケンスは "under." で、*: は二乗です。

Also see the follow-up.

(If you liked this, you might enjoy Understanding What It's Like to Program in Forth.)
January 3, 2012
prog21: Follow-up to "A Programming Idiom You've Never Heard Of"

Follow-up to "A Programming Idiom You've Never Heard Of"

Lots of mail, lots of online discussion about A Programming Idiom You've Never Heard Of,
so I wanted to clarify a few things.

A Programming Idiom You've Never Heard Of に関して、多くのメールがあり、また
online discussion がありました。

What I was trying to do was get across the unexpected strangeness of function inverses in a
programming language. In that short definition of vector magnitude, there wasn't a visible
square root function. There was only an operator for squaring a value, and another operator
that involved inverting a function.

the unexpected strangeness of function inverses
を get acrross することです。
vector magnitude の short definition においては
visible な square root 関数はなかったのです。
もうひとつあったのがある関数を invert した結果を得る演算子でした。

How does the J interpreter manage to determine a function inverse at runtime? For many
primitives, there's an associated inverse. The inverse of add is subtract. The inverse of
increment is decrement. For some primitives there isn't a true, mathematical inverse, but a
counterpart that's often useful. That's why the preferred term in J isn't inverse, but obverse.

J のインタープリターは実行時にある関数の inverse を決定するためにどのような管理を
行っているのでしょうか? 多くのプリミティブに対しては、結び付けられた inverse があります。
add の inverse は subtract で、incrrement の inverse は decrement です。
一部のプリミティブでは数学的な inverse  ではないものもありますが、
有用なことが頻繁であるような counterpart です。
それが、J における prefered term が inverse でなく obverse である理由です。

For user-defined functions, there's an attempt at inversion (er, obversion) that works 
much of the time. A function that reverses a list then adds five to each element turns 
into a function that subtracts five from each element then reverses the list. For 
cases where the automated obverse doesn't work, or where you want the obverse to have 
different behavior, you can associate a user-defined obverse with any verb (J lingo 
for function). You could define an open_file verb which opens a file and has an 
obverse that closes a file. Or in actual J:

  open_file =: open :. close

Well, really, that should be:

  open_file =: (1!:21) :. (1!:22)

But the former, without the explicit foreign function calls, gets the point across clearer,
I think.

One common use of obverses and the "under" operator is for boxing and unboxing
values. In J, a list contains values of the same type. There's no mixing of integers and
strings like Lisp or Python. Instead you can "box" a value, then have a list
containing only boxed values. But there's nothing you can do with a boxed value except
unbox it, so it's common to say "[some operation] under open box," like "
increment under open box." That means unbox the value, increment it, then put it back
in a box. Or in real, eyeball-melting J:

  inc_box =: >: &. >

The >: is increment. The right > means open box. That's the "under" 
operation in the middle.

Now it sounds like this "open box, do something, close box" sequence would 
translate beautifully to the "open file, read the contents, close the file" 
example I gave last time, but it doesn't. The catch is that the open / read / close 
verbs aren't manipulating a single input the way inc_box is. Opening a file returns a 
handle, which gets passed to read. But reading a file returns the contents of the file, 
which is not something that can be operated on by close. So this definition won't work:

  read_file =: read &. open

If a structured data type like a dictionary was being passed around, then okay, but 
that's not a pretty example like I hoped it would be.

Still, I encourage learning J, if only to make every other language seem easy. 

■_ regexp

5.14 のソースは初めて見たのだけど、変わりっぷりに唖然呆然。 以前の面影もあるっちゃああるんだけどねえ。

regexec.c 2991

STATIC I32			/* 0 failure, 1 success */
S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog)
#if PERL_VERSION < 9 && !defined(PERL_CORE)
    register const bool utf8_target = PL_reg_match_utf8;
    const U32 uniflags = UTF8_ALLOW_DEFAULT;
    REGEXP *rex_sv = reginfo->prog;
    regexp *rex = (struct regexp *)SvANY(rex_sv);
    I32	oldsave;
    /* the current state. This is a cached copy of PL_regmatch_state */
    register regmatch_state *st;
    /* cache heavy used fields of st in registers */
    register regnode *scan;
    register regnode *next;
    register U32 n = 0;	/* general value; init to avoid compiler warning */
    register I32 ln = 0; /* len or last;  init to avoid compiler warning */
    register char *locinput = PL_reginput;
    register I32 nextchr;   /* is always set to UCHARAT(locinput) */

    bool result = 0;	    /* return value of S_regmatch */
    int depth = 0;	    /* depth of backtrack stack */
    U32 nochange_depth = 0; /* depth of GOSUB recursion with nochange */
    const U32 max_nochange_depth =
        (3 * rex->nparens > MAX_RECURSE_EVAL_NOCHANGE_DEPTH) ?
        3 * rex->nparens : MAX_RECURSE_EVAL_NOCHANGE_DEPTH;
    regmatch_state *yes_state = NULL; /* state to pop to on success of
							    subpattern */
    /* mark_state piggy backs on the yes_state logic so that when we unwind 
       the stack on success we can update the mark_state as we go */
    regmatch_state *mark_state = NULL; /* last mark state we have seen */
    regmatch_state *cur_eval = NULL; /* most recent EVAL_AB state */
    struct regmatch_state  *cur_curlyx = NULL; /* most recent curlyx */
    U32 state_num;
    bool no_final = 0;      /* prevent failure from backtracking? */
    bool do_cutgroup = 0;   /* no_final only until next branch/trie entry */
    char *startpoint = PL_reginput;
    SV *popmark = NULL;     /* are we looking for a mark? */
    SV *sv_commit = NULL;   /* last mark name seen in failure */
    SV *sv_yes_mark = NULL; /* last mark name we have seen 
                               during a successful match */
    U32 lastopen = 0;       /* last open we saw */
    bool has_cutgroup = RX_HAS_CUTGROUP(rex) ? 1 : 0;   
    SV* const oreplsv = GvSV(PL_replgv);
    /* these three flags are set by various ops to signal information to
     * the very next op. They have a useful lifetime of exactly one loop
     * iteration, and are not preserved or restored by state pushes/pops
    bool sw = 0;	    /* the condition value in (?(cond)a|b) */
    bool minmod = 0;	    /* the next "{n,m}" is a "{n,m}?" */
    int logical = 0;	    /* the following EVAL is:
				0: (?{...})
				1: (?(?{...})X|Y)
				2: (??{...})
			       or the following IFMATCH/UNLESSM is:
			        false: plain (?=foo)
				true:  used as a condition: (?(?=foo))
	case TRIE:
	    /* the basic plan of execution of the trie is:

	case EXACT: {
	case EXACTFL: {
	    re_fold_t folder;
	    const U8 * fold_array;
	    const char * s;
	    U32 fold_utf8_flags;

	    PL_reg_flags |= RF_tainted;
	    folder = foldEQ_locale;
	    fold_array = PL_fold_locale;
	    fold_utf8_flags = FOLDEQ_UTF8_LOCALE;
	    goto do_exactf;

	case EXACTFU:
	    folder = foldEQ_latin1;
	    fold_array = PL_fold_latin1;
	    fold_utf8_flags = 0;
	    goto do_exactf;

	case EXACTFA:
	    folder = foldEQ_latin1;
	    fold_array = PL_fold_latin1;
	    fold_utf8_flags = FOLDEQ_UTF8_NOMIX_ASCII;
	    goto do_exactf;

	case EXACTF:
	    folder = foldEQ;
	    fold_array = PL_fold;
	    fold_utf8_flags = 0;

	    s = STRING(scan);
	    ln = STR_LEN(scan);

	    if (utf8_target || UTF_PATTERN) {
	      /* Either target or the pattern are utf8. */
		const char * const l = locinput;
		char *e = PL_regeol;

		if (! foldEQ_utf8_flags(s, 0,  ln, cBOOL(UTF_PATTERN),
			       l, &e, 0,  utf8_target, fold_utf8_flags))
		locinput = e;
		nextchr = UCHARAT(locinput);

	    /* Neither the target nor the pattern are utf8 */
	    if (UCHARAT(s) != nextchr &&
		UCHARAT(s) != fold_array[nextchr])
	    if (PL_regeol - locinput < ln)
	    if (ln > 1 && ! folder(s, locinput, ln))
	    locinput += ln;
	    nextchr = UCHARAT(locinput);
	case REFFL:
	    PL_reg_flags |= RF_tainted;
	    folder = foldEQ_locale;
	    fold_array = PL_fold_locale;
	    utf8_fold_flags = FOLDEQ_UTF8_LOCALE;
	    goto do_ref;

	case REFFA:
	    folder = foldEQ_latin1;
	    fold_array = PL_fold_latin1;
	    utf8_fold_flags = FOLDEQ_UTF8_NOMIX_ASCII;
	    goto do_ref;

	case REFFU:
	    folder = foldEQ_latin1;
	    fold_array = PL_fold_latin1;
	    utf8_fold_flags = 0;
	    goto do_ref;

	case REFF:
	    folder = foldEQ;
	    fold_array = PL_fold;
	    utf8_fold_flags = 0;
	    goto do_ref;

        case REF:
	    folder = NULL;
	    fold_array = NULL;
	    utf8_fold_flags = 0;

	    type = OP(scan);
	    n = ARG(scan);  /* which paren pair */

	    ln = PL_regoffs[n].start;
	    PL_reg_leftiter = PL_reg_maxiter;		/* Void cache */
	    if (*PL_reglastparen < n || ln == -1)
		sayNO;			/* Do not match unless seen CLOSEn. */
	    if (ln == PL_regoffs[n].end)

    /* clean up; in particular, free all slabs above current one */

    return result;

巨大 switch がさらに成長してた…



=for apidoc foldEQ

Returns true if the leading len bytes of the strings s1 and s2 are the same
case-insensitively; false otherwise.  Uppercase and lowercase ASCII range bytes
match themselves and their opposite case counterparts.  Non-cased and non-ASCII
range bytes match only themselves.


Perl_foldEQ(const char *s1, const char *s2, register I32 len)
    register const U8 *a = (const U8 *)s1;
    register const U8 *b = (const U8 *)s2;


    while (len--) {
	if (*a != *b && *a != PL_fold[*b])
	    return 0;
    return 1;
Perl_foldEQ_latin1(const char *s1, const char *s2, register I32 len)
    /* Compare non-utf8 using Unicode (Latin1) semantics.  Does not work on
     * LATIN_SMALL_LETTER_Y_WITH_DIAERESIS, and does not check for these.  Nor
     * does it check that the strings each have at least 'len' characters */

    register const U8 *a = (const U8 *)s1;
    register const U8 *b = (const U8 *)s2;


    while (len--) {
	if (*a != *b && *a != PL_fold_latin1[*b]) {
	    return 0;
	a++, b++;
    return 1;

=for apidoc foldEQ_locale

Returns true if the leading len bytes of the strings s1 and s2 are the same
case-insensitively in the current locale; false otherwise.


Perl_foldEQ_locale(const char *s1, const char *s2, register I32 len)
    register const U8 *a = (const U8 *)s1;
    register const U8 *b = (const U8 *)s2;


    while (len--) {
	if (*a != *b && *a != PL_fold_locale[*b])
	    return 0;
    return 1;


/* fast conversion and case folding tables.  The folding tables complement the
 * fold, so that 'a' maps to 'A' and 'A' maps to 'a', ignoring more complicated
 * folds such as outside the range or to multiple characters. */

#ifdef DOINIT
#ifndef EBCDIC

/* The EBCDIC fold table depends on the code page, and hence is found in
 * utfebcdic.h */

EXTCONST  unsigned char PL_fold[] = {
	0,	1,	2,	3,	4,	5,	6,	7,
	248,	249,	250,	251,	252,	253,	254,	255
EXTCONST  unsigned char PL_fold_latin1[] = {
    /* Full latin1 complement folding, except for three problematic code points:
     *	Micro sign (181 = 0xB5) and y with diearesis (255 = 0xFF) have their
     *	fold complements outside the Latin1 range, so can't match something
     *	that isn't in utf8.
     *	German lower case sharp s (223 = 0xDF) folds to two characters, 'ss',
     *	not one, so can't be represented in this table.
     * All have to be specially handled */
	0,	1,	2,	3,	4,	5,	6,	7,
	176,	177,	178,	179,	180,	181 /*micro */,	182,	183,
	184,	185,	186,	187,	188,	189,	190,	191,
	192+32,	193+32,	194+32,	195+32,	196+32,	197+32,	198+32,	199+32,
	200+32,	201+32,	202+32,	203+32,	204+32,	205+32,	206+32,	207+32,
	208+32,	209+32,	210+32,	211+32,	212+32,	213+32,	214+32,	215,
	216+32,	217+32,	218+32,	219+32,	220+32,	221+32,	222+32,	223 /* ss */,
	224-32,	225-32,	226-32,	227-32,	228-32,	229-32,	230-32,	231-32,
	232-32,	233-32,	234-32,	235-32,	236-32,	237-32,	238-32,	239-32,
	240-32,	241-32,	242-32,	243-32,	244-32,	245-32,	246-32,	247,
	248-32,	249-32,	250-32,	251-32,	252-32,	253-32,	254-32,
	255 /* y with diaeresis */
#endif  /* !EBCDIC, but still in DOINIT */

/* If these tables are accessed through ebcdic, the access will be converted to
 * latin1 first */
EXTCONST  unsigned char PL_latin1_lc[] = {  /* lowercasing */
	0,	1,	2,	3,	4,	5,	6,	7,
	192+32,	193+32,	194+32,	195+32,	196+32,	197+32,	198+32,	199+32,
	200+32,	201+32,	202+32,	203+32,	204+32,	205+32,	206+32,	207+32,
	208+32,	209+32,	210+32,	211+32,	212+32,	213+32,	214+32,	215,
	216+32,	217+32,	218+32,	219+32,	220+32,	221+32,	222+32,	223,	
	224,	225,	226,	227,	228,	229,	230,	231,
	232,	233,	234,	235,	236,	237,	238,	239,
	240,	241,	242,	243,	244,	245,	246,	247,
	248,	249,	250,	251,	252,	253,	254,	255

/* upper and title case of latin1 characters, modified so that the three tricky
 * ones are mapped to 255 (which is one of the three) */
EXTCONST  unsigned char PL_mod_latin1_uc[] = {
	0,	1,	2,	3,	4,	5,	6,	7,
	216,	217,	218,	219,	220,	221,	222,	255 /*sharp s*/,	
	224-32,	225-32,	226-32,	227-32,	228-32,	229-32,	230-32,	231-32,
	232-32,	233-32,	234-32,	235-32,	236-32,	237-32,	238-32,	239-32,
	240-32,	241-32,	242-32,	243-32,	244-32,	245-32,	246-32,	247,
	248-32,	249-32,	250-32,	251-32,	252-32,	253-32,	254-32,	255
#else	/* ! DOINIT */
EXTCONST unsigned char PL_fold[];
EXTCONST unsigned char PL_fold_latin1[];
EXTCONST unsigned char PL_mod_latin1_uc[];
EXTCONST unsigned char PL_latin1_lc[];

#ifndef PERL_GLOBAL_STRUCT /* or perlvars.h */
#ifdef DOINIT
EXT unsigned char PL_fold_locale[] = { /* Unfortunately not EXTCONST. */
	0,	1,	2,	3,	4,	5,	6,	7,
	8,	9,	10,	11,	12,	13,	14,	15,
	16,	17,	18,	19,	20,	21,	22,	23,
	24,	25,	26,	27,	28,	29,	30,	31,
	32,	33,	34,	35,	36,	37,	38,	39,
	40,	41,	42,	43,	44,	45,	46,	47,
	48,	49,	50,	51,	52,	53,	54,	55,
	56,	57,	58,	59,	60,	61,	62,	63,
	64,	'a',	'b',	'c',	'd',	'e',	'f',	'g',
	'h',	'i',	'j',	'k',	'l',	'm',	'n',	'o',
	'p',	'q',	'r',	's',	't',	'u',	'v',	'w',
	'x',	'y',	'z',	91,	92,	93,	94,	95,
	96,	'A',	'B',	'C',	'D',	'E',	'F',	'G',
	'H',	'I',	'J',	'K',	'L',	'M',	'N',	'O',
	'P',	'Q',	'R',	'S',	'T',	'U',	'V',	'W',
	'X',	'Y',	'Z',	123,	124,	125,	126,	127,
	128,	129,	130,	131,	132,	133,	134,	135,
	136,	137,	138,	139,	140,	141,	142,	143,
	144,	145,	146,	147,	148,	149,	150,	151,
	152,	153,	154,	155,	156,	157,	158,	159,
	160,	161,	162,	163,	164,	165,	166,	167,
	168,	169,	170,	171,	172,	173,	174,	175,
	176,	177,	178,	179,	180,	181,	182,	183,
	184,	185,	186,	187,	188,	189,	190,	191,
	192,	193,	194,	195,	196,	197,	198,	199,
	200,	201,	202,	203,	204,	205,	206,	207,
	208,	209,	210,	211,	212,	213,	214,	215,
	216,	217,	218,	219,	220,	221,	222,	223,	
	224,	225,	226,	227,	228,	229,	230,	231,
	232,	233,	234,	235,	236,	237,	238,	239,
	240,	241,	242,	243,	244,	245,	246,	247,
	248,	249,	250,	251,	252,	253,	254,	255
EXT unsigned char PL_fold_locale[]; /* Unfortunately not EXTCONST. */
#endif /* !PERL_GLOBAL_STRUCT */

ここで PL_fold_locale に注目すると


 * Set up for a new ctype locale.
Perl_new_ctype(pTHX_ const char *newctype)
    int i;


    for (i = 0; i < 256; i++) {
	if (isUPPER_LC(i))
	    PL_fold_locale[i] = toLOWER_LC(i);
	else if (isLOWER_LC(i))
	    PL_fold_locale[i] = toUPPER_LC(i);
	    PL_fold_locale[i] = i;

#endif /* USE_LOCALE_CTYPE */

ふむ。locale.c には他にも色々と興味深い(泥臭い)お助け関数群があった。 でかい文字集合のエンコーディングを扱うときは…ってのは次回以降(気が向いたら)。

alternative の最適化で trie 作るとかも確かに入ってますね。 これは5.14 からではないけど。

■_ The World's Worst Scripting Language

VirtualDub scripting language reference, v0.7 について。 「世界最悪」なんてついてたので気になったw

Sylia: The World's Worst Scripting Language. "I don't know what I was thinking when I created this scripting language. It's very loosely based on C, but it sucks more." : programming

Some miscellaneous history behind VirtualDub's scripting language:

スクリプティング言語 VirtualDub's には隠されたいくつかの miscellaneous history があります

The original version of the interpreter dates back at least to 2002. I didn't know very much
about writing a parser or designing a language back then, and neither C nor assembly were
very good role models. I did at least use an operator-precedence parser for expressions,
which is much more compact than a recursive descent expression parser.

また、C もアセンブリ言語もより role model ではありませんでした。

The way that commands are described internally was originally inspired by the extension
mechanism of AMOS Professional. Unfortunately, this meant that it was lacking in support for
namespacing or classes, and allows variadic type returns which I wouldn't have been in favor
of later on.

The interpreter uses garbage collection for strings but does a full sweep for every function
call. It wasn't a high priority when you could only declare one variable at a time and many
of the function calls you could make would take hours to complete (i.e. rendering a video).

Later versions of the interpreter added support for floating-point values, 64-bit integers,
and Unicode strings. The first two required adding parameter type based overloading to the
interpreter, leading to significant complexity in the function call dispatch code, but is
otherwise pretty standard with regard to type matching and implicit conversion rules. The
Unicode support is nastier because it was added to the parser instead of the core, which
still uses 8-bit strings without a defined encoding, and thus places the onus on the
programmer to manually use either an MBCS or UTF-8 string depending on what the called
function expects (some of which may be from plugins that don't accept UTF-8).

Some of the reasons behind the lack of flow control are that the interpreter accepts 
one line at a time and that it does not have a pre-tokenized form. Another is that the 
lack of flow control means that scripts cannot get stuck in an infinite loop and 
always progress, which is actually a boon considering that scripts execute 
synchronously in the UI thread. The most serious, though, is that the interpreter is 
not able to parse code which contains references to undefined variables, which means 
it could not properly skip past a non-executed if() or while() statement body. This 
would have been easier if newlines were statement delimiters instead of semicolons, 
but as a C/C++ programmer I have a preference for the latter.

I really wish I'd used "var" instead of "declare" for variable declaration,
for consistency with everyone else.

The biggest problem with the scripting language is actually the way it was used, to save
settings. If you can help it, never use a scripting language as a serialization or
interchange format. It means that only the original program can fully interpret the file,
and then only with significant baggage. The language can't be replaced with a more standard
one like Lua because it is now ingrained in scripts and in the filter API.

Hey Avery. I posted this link in jest. I use VDub all the time, and it's one of the 
most handy applications I've ever come across. Just giving credit where it's due.

Heh... thanks. I wasn't offended, just amused.

Thinking back to when I wrote that code, I think the only languages I had really used 
at the time were assembly language, C/C++, BASIC, Java, and Pascal. None of these were 
good role models for a scripting language. :)

Time to rewrite the software from scratch.

The practical solution would be to deprecate Sylvia and start using Lua.

Or, heaven forbid, Guile.

Guile isn't that bad.

When PHP developers hear about this, I bet they'll switch.

なんか PHP ネタが多いなあ>このあとの流れ






GIGAZINE にも取り上げられたか なぜプログラマを難問奇問・一風変わったテストなどで雇ってはいけないのか? - GIGAZINE

一昨日辺りから Hacker News や reddit でも結構盛り上がってます Why 37signals doesn't hire programmers based on puzzles, API quizzes, math riddles, or other parlor tricks : programming Why 37signals Doesn't Hire Programmers Based on Brainteasers | Hacker News で、Hacker News の方にはこういう人も Interview and hiring techniques are a perennial favourite on HN. I just have a couple of comments (disclaimer: I work for Google). I personally detest abstract puzzles like "why are manhole covers round?" or (worse) "How do you move Mount Fuji?" AFAIK these types of questions are not and have never been used in engineering hiring at Google (sales, etc I know nothing about). WSJ and other sources have made this (AFAIK inaccurate) claim. It's possible individual interviewers do this. My own philosophy is that a simple whiteboard coding problem is an incredibly useful litmus test. I don't mean anything incredibly complicated either. If you can't write a function that gives me a row of Pascall's triangle, that's a problem. Note: I don't expect you to know what Pascall's Triangle is, merely implement it when explained. この後も結構書いてますがこの辺りまで。

Interview Programming Problems Done Right ~ C for Coding


APL はちょっとやりたいと思ってる。 J でもいいけど。

Ruby 初心者スレッド Part 47

828 デフォルトの名無しさん [sage] 2012/01/07(土) 10:31:21.84 ID: Be:

■_ A+D=P

明倫館で状態のいい古本を買ったなあ> アルゴリズム+データ構造=プログラム

スレ立てるまでもない質問はここで 115匹目

927 デフォルトの名無しさん [sage] 2012/01/07(土) 18:35:06.49 ID: Be:

928 デフォルトの名無しさん [sage] 2012/01/07(土) 18:40:27.77 ID: Be:

929 デフォルトの名無しさん [sage] 2012/01/07(土) 18:43:29.39 ID: Be:


930 デフォルトの名無しさん [sage] 2012/01/07(土) 18:48:05.88 ID: Be:


931 デフォルトの名無しさん [sage] 2012/01/07(土) 18:50:34.16 ID: Be:

932 930 [sage] 2012/01/07(土) 19:02:42.74 ID: Be:

復刊.com ではソフトカバーの廉価版で~ という意見もあったけどいっそ電書で(ry

■_ Emacs

Emacs Part 39

587 名無しさん@お腹いっぱい。 [sage] 2012/01/07(土) 16:21:58.76 ID: Be:
    ELPAの作者がemacsをcommon lispで書き直そうとしているみたい
    The Cliffs of Inanity ? Emacs and Common Lisp http://tromey.com/blog/?p=709
    そうなると長い目で見ればcommon lispを知っておいた方がよさそう 

588 名無しさん@お腹いっぱい。 [sage] 2012/01/07(土) 16:26:03.17 ID: Be:
    EmacsをCommon Lispでって・・・・
    10年前に Erik Naggum が言ってたのと同じことやん。

590 名無しさん@お腹いっぱい。 [sage] 2012/01/07(土) 17:10:02.39 ID: Be:
    このあたりの話が関係するか。emacsをcommon lispで、っていうのは真っ正面から議論されていたのかな?
    Island Life - 「Cで書くコードの方がCommon Lispで書くより速いって人がいたら、それは彼のCの技量が高すぎるってことだね。」

591 名無しさん@お腹いっぱい。 [sage] 2012/01/07(土) 17:15:34.53 ID: Be:
    guile emacs の方がいいよ

    それはそうと emacs 24で`image-library-alist' is renamed to `dynamic-library-alist' ってなってるの見て

594 名無しさん@お腹いっぱい。 [sage] 2012/01/07(土) 17:51:12.15 ID: Be:

596 名無しさん@お腹いっぱい。 [sage] 2012/01/07(土) 18:03:58.85 ID: Be:


The Cliffs of Inanity › Emacs and Common Lisp

Emacs and Common Lisp

Recently I've been thinking about how to rebase Emacs on Common Lisp.

最近になって、わたしは Emacs を Common Lisp にどのように rebase するかについて

First, why rebase?  Performance is the biggest reason.  Emacs Lisp is a very basic lisp
implementation.  It has a primitive garbage collector and basic execution model, and due to
how it is written, it is quite hard to improve this in place.

まず、なぜ rebase なのでしょうか? 性能がもっとも大きな理由です。Emacs Lisp は非常に basic な
lisp 実装であり、primitive なガーベジコレクションと basic execution modelを持っていて

Seccond, why Common Lisp?  Two reasons: first, Emacs Lisp resembles Common Lisp in many ways;
elisp is like CL's baby brother.  Second, all of the hard problems in Lisp execution have
already been solved excellently by existing, free-software CL implementations.  In particular,
the good CL implementations have much better garbage collectors, native compilation, threads,
and FFI; we could expose the latter two to elisp in a straightforward way.

次に、なぜ Common Lisp なのか? これには二つ理由があります。
第一に、Emacs Lisp は多くの点で Common Lisp に似ているからです。
Emacs Lisp は Common Lisp の baby brother のようなものです。
第二に、Lisp の実行における困難な問題のすべては、
現存するフリーソフトウェアの Common Lisp の実装ですでに excellently に解決されているからです。
とりわけ、優れた Common Lisp 実装は格段に性能の良いガーベジコレクションを持ち、
ネイティブコンパイル、スレッド、FFI もあります。
そしてこの最後の二つを straightfoward なやりかたで elisp に expose できるでしょう。

By “rebase” I mean something quite ambitious — rewrite the C source of Emacs into Common
Lisp.  I think this can largely be automated via a GCC plugin (e.g., written using David
Malcolm's Python plugin).  Full automation would let the CL port be just another way to
build Emacs, following the upstream development directly until all the Emacs maintainers can
be convinced to drop C entirely (cough, cough).

By “rebase” I mean something quite ambitious ―
Cで書かれた Emacs のソースを Common Lisp で書き直す。
(David Malcom の Python プラグインを使って書かれた)
GCC のプラグインを使って大部分は自動で行えるだろうとわたしは考えています。

Full automation would let the CL port be just another way to build Emacs,
following the upstream development directly
until all the Emacs maintainers can be convinced to drop C entirely (cough, cough).

full automation は Common Lisp への移植を単なるもう一つの Emacs ビルド手順にしてしまうでしょう。

Part of the rewrite would be dropping code that can be shared with CL.  For example, we don't
need to translate the Emacs implementation of “cons”, we can just use the CL one.

書き直しの一部はCommon Lisp と共有できるコードの削除 (dropping code) になるでしょう。
たとえば、Emacs の “cons”の実装は Common Lisp のそれを使えるのですから

Some CL glue would be needed to make this all work properly.  These days it can't be quite
as small as elisp.lisp, but it still would not need to be very big.  The trickiest problem
is dealing with buffer-local variables; but I think that can be done by judicious use of
define-symbol-macro in the elisp reader.

一部の Common Lisp glue がこれをすべて適切に行うのに必要になるでしょう。
今日のそれは elisp.lisp ほど小さいものにはできませんが、
trickiest problem は バッファーローカルの変数群ですが、
Emacs Lisp リーダー中での define-symbol-macro の judicious use によって解決できると考えています。

Emacs might be the only program in the world that would see a performance improvement from
rewriting in CL :-) .  The reason for this is simple: Emacs' performance is largely related
to how well it executes lisp code, and how well the GC works.

Emacs は Common Lisp で書きかえることによって性能が向上するのを確認できる
世界で唯一のプログラムかもしれません :-)
Emacs の性能は lisp コードをどのくらい効率よく実行するか
や GC がどれだけ効率よく動作するかに大きく依存しているからです。

This was written by tom. Posted on Thursday, January 5, 2012, at 5:40 pm.

    Brett wrote:

    This is also something the GNU Guile (Scheme) guys have talked about for years. I'm not
    sure if they've started work in earnest, but part of their plan was that Guile would be
    used to implement other languages (Elisp, CL, JavaScript) for people that prefered them
    or need them for backwards compatability.

    tom wrote:

    I know about the Guile stuff. I think it is a really bad idea — while it seems similar
    to what I am proposing, it is actually quite different and won't provide the same
    benefits at all. I occasionally rant about this on #emacs, maybe someday I will turn
    that rant into a blog post explaining what is so wrong about it.

    shazbot wrote:

    I would rather see an Emacs implementation on Ruby or another modern scripting language
    that fully supports the functional programming paradigm.
    Friday, January 6, 2012 at 12:04 am

    David wrote:

    I think you have a slightly skewed view on the Emacs C source. Interpreting Emacs Lisp
    is a pretty tiny part. Just do

    cd emacs/trunk/src
    wc *.c | sort -n

    and see what the C code deals with. It's mostly redisplay, and it would surely not
    profit from a CL rewrite at all (if that's even possible, which I doubt). That code
    is so furiously complicated that almost no one dares to touch it. The other main parts
    are the event loop, X communication, character coding, image support, subprocesses,
    and so on.

■_ アレ

Emacs Part 39

601 名無しさん@お腹いっぱい。 [sage] 2012/01/07(土) 22:46:09.78 ID: Be:

    (require 'cl)
    ; cl

    (defun mapbetween (f l)
    (let (y)
    (mapl #'(lambda (x)
    (when (cadr x)
    (push (funcall f (cadr x) (car x)) y)))
    (nreverse y)))
    ; mapbetween

    (mapbetween #'+ '(1 2 3 4 5))
    ; (3 5 7 9)

    (mapbetween #'- '(0 1 4 9))
    ; (1 3 5) 





この本は、管理職(笑)ではなく選手に該当するような人に読んで欲しいのね。 彼が選手にどういうもの(行動やら意識やら)を求めていたのかを読んで、 自分はどうあるべきか考えるとか。

歴史群像 2012年 02月号 [雑誌]

マッキントッシュ伝説 林檎の樹の下で ~アップルはいかにして日本に上陸したのか~
読み終わったのはちょっと前なんですが。 林檎の~の方で、一向に進まなかった Mac の日本語対応があることをきっかけに見違えるように 進展したのですがそれは… 読んで確かめていただくとして、なんともらしいよねえと思った次第。

いやこんなんにあったのね 今こそまとめ読み!技術系アドベントカレンダー総まとめ 2011【完結】 – OTCHY.NET

■_ tail+cut+awk

今日のワンライナー - Yet Another Hackadelic

ヘッダ付き CSV の2列目の各行の数値の和を求める、ってのがさらっと書けなかったので社内で聞いたみた。

$ tail -n '+1' mojage.csv | cut -d "," -f 2 | awk '{ s+=$1 } END { print s }'


$ paste -d '+' -s ./mojage.csv | bc

みたいな奴。正確には一時ファイルが必要だけど、bc に食わすってのがちょっとお洒落さんだなーと。

最初の例、cut 必要なんでしょうか? awk のところを awk -F, '{s+=$2} END{print s}' と変えれば行けると思うんだけど。

さらに言えばtailも要らない? awk -F, 'NR>1{s+=$2} END{print s}'

>paste --help
Usage: paste [OPTION]... [FILE]...
Write lines consisting of the sequentially corresponding lines from
each FILE, separated by TABs, to standard output.
With no FILE, or when FILE is -, read standard input.

Mandatory arguments to long options are mandatory for short options too.
  -d, --delimiters=LIST   reuse characters from LIST instead of TABs
  -s, --serial            paste one file at a time instead of in parallel
      --help     display this help and exit
      --version  output version information and exit

-s オプション知らなかったw まあこれも awk で awk -vORS='+' '1' ./mojagecsv とか… あ、これだと尻尾に余計な'+'が残るか。


なんかコード片が Ruby っぽい印象が。

State of Dancer on Perl 6 « Whatever but Cool

State of Dancer on Perl 6
Posted: 06/01/2012 | Author: ttjjss 

Bailador is growing better and bigger and starts to resemble a real tool more and more. Let's
see what new features it has gained recently.

Remember the first example in perldoc Dancer? It's not really different in Bailador:

  use Bailador;
  get '/hello/:name' => sub ($name) {
      return "Why, hello there $name"

Aside of being a little Spanished, what did it give us? We have subroutine signatures in
Perl 6 so we can pass the :name parameter to the sub; there's no need to use param() now:
it's gone.

Perl 6 にはサブルーチンのシグネチャーがあるので、上記の sub に :name パラメーターを
渡すことができて、param() を使う必要はなくなりました。今はもうありません。

You don't need to pass everything using GET of course. post keyword is also supported.
すべてを GETを使って渡す必要というのはもちろんなくて、post キーワードもサポートされています。

  post '/' => sub {
      return request.params.perl

The above will print something like ("foo" => "bar").hash, if fed
with appropriate request.

("foo" => "bar").hash

any() is a reserved keyword in Perl 6, and while you can use it, it means a completely 
different thing. Instead of any('get', 'post') you can just do it like this:

any('get', 'post') の代わりに次のように記述できます

  get post '/' => sub {
      if request.is_get {
          return "I am GET"
      } else {
          return request.params.perl

post, as well as get return their arguments, so you can chain them like in the example 
above. It also shows the joy of request object, which you can use to inspect the request
being processed. It's not as cool as Dancer::Request, but it does the job, being quite
small and simple.

post は get と同様にその引数を返すので先にあげた例のように繋げていくことが可能です。
同様に、処理されているリクエストを inspect するのに使えるリクエストオブジェクトも
例示しています。これは Dancer::Request ほどには cool ではありませんが、

What else do we have? Let's show off a bit and write a simple-simple pastebin webapp.


  use Bailador;
  unless 'data'.IO ~~ :d {
      mkdir 'data'
  get '/' => sub {
      template 'index.tt'
  post '/new_paste' => sub {
      my $t  = time;
      my $c = request.params<content>;
      unless $c {
          return "No empty pastes please";
      my $fh = open "data/$t", :w;
      $fh.print: $c;
      return "New paste available at paste/$t";
  get /paste\/(.+)/ => sub ($tag) {
      content_type 'text/plain';
      if "data/$tag".IO.f {
          return slurp "data/$tag"
      status 404;
      return "Paste does not exist";







Tim O'Reilly も Google+ 使ってたのかー Tim O'Reilly - Google+ - The ideas from +Clay Johnson's new book, The Information… Amazon.com: The Information Diet: A Case for Conscious Consumption (9781449304683): Clay A. Johnson: Books

試しに「憂国のラスプーチン」のコミックの単行本、一巻だけ買ってみた (現在三巻まで)。

■_ 10

IT を shake up するかもしれないプログラミング言語十個。

10 programming languages that could shake up IT

10 programming languages that could shake up IT
By Neil McAllister
Created 2012-01-03 03:00AM


Here, then, is a look at 10 cutting-edge programming languages, each of which approaches
the art of software development from a fresh perspective, tackling a specific problem or
a unique shortcoming of today's more popular languages. Some are mature projects, while
others are in the early stages of development. Some are likely to remain obscure, but any
one of them could become the breakthrough tool that changes programming for years to come
-- at least, until the next batch of new languages arrives.

Experimental programming language No. 1: Dart


Experimental programming language No. 2: Ceylon


Experimental programming language No. 3: Go

Interpreters, virtual machines, and managed code are all the rage these days. Do we really
need another old-fashioned language that compiles to native binaries? A team of Google
engineers -- led by Robert Griesemer and Bell Labs legends Ken Thompson and Rob Pike -- says yes.

Go is a general-purpose programming language suitable for everything from application
development to systems programing. In that sense, it's more like C or C++ than Java or 
C#. But like the latter languages, Go includes modern features such as garbage collection,
runtime reflection, and support for concurrency.

Go はアプリケーション開発からシステムプログラミングに到るまでのすべてに使えるような
汎用のプログラミング言語です。そのような意味合いにおいて、この言語は Java や C#
よりは C や C++ に似た言語です。
しかし後者の言語と同様、Go はガーベジコレクションだとか実行時リフレクションのような
modern な機能を持っており、concurrency をサポートしています。


Experimental programming language No. 4: F#


Experimental programming language No. 5: Opa

Web development is too complicated. Even the simplest Web app requires countless lines of
code in multiple languages: HTML and JavaScript on the client, Java or PHP on the server,
SQL in the database, and so on.

Web 開発は複雑すぎます。
単純な Web アプリでさえ複数の言語で書かれた数え切れないほどの行のコードを必要とします。
クライアントではHTML と JavaScript、サーバーでは Java か PHP、
データベースでは SQL などなど。

Opa doesn't replace any of these languages individually. Rather, it seeks to eliminate them
all at once, by proposing an entirely new paradigm for Web programming. In an Opa application,
the client-side UI, server-side logic, and database I/O are all implemented in a single
language, Opa.

Opa はこれらの言語のどれかを individually に置き換えるものではありません。
そのような言語すべてをいちどきに elminate することを目指しているものです。
あるひとつの Opa アプリケーションでは、クライアントサイドのUI、
サーバーサイドのロジック、そしてデータベースのI/O といったものはすべて
単一の言語 Opa によって実装されます。


Experimental programming language No. 6: Fantom

Should you develop your applications for Java or .Net? If you code in Fantom, you can 
take your pick and even switch platforms midstream. That's because Fantom is designed 
from the ground up for cross-platform portability. The Fantom project includes not 
just a compiler that can output bytecode for either the JVM or the .Net CLI, but also 
a set of APIs that abstract away the Java and .Net APIs, creating an additional 
portability layer.

There are plans to extend Fantom's portability even further. A Fantom-to-JavaScript 
compiler is already available, and future targets might include the LLVM compiler 
project, the Parrot VM, and Objective-C for iOS.


Experimental programming language No. 7: Zimbu

Most programming languages borrow features and syntax from an earlier language. Zimbu 
takes bits and pieces from almost all of them. The brainchild of Bram Moolenaar, 
creator of the Vim text editor, Zimbu aims to be a fast, concise, portable, and 
easy-to-read language that can be used to code anything from a GUI application to an 
OS kernel.


Vim というテキストエディターの作者である Bram Moolenear の brainchild である Zimbu は
GUI アプリケーションからOSのカーネルまでも対象とできるような


Experimental programming language No. 8: X10

Parallel processing was once a specialized niche of software development, but with the 
rise of multicore CPUs and distributed computing, parallelism is going mainstream. 
Unfortunately, today's programming languages aren't keeping pace with the trend. 
That's why IBM Research is developing X10, a language designed specifically for modern 
parallel architectures, with the goal of increasing developer productivity "times 


Experimental programming language No. 9: haXe

Lots of languages can be used to write portable code. C compilers are available for 
virtually every CPU architecture, and Java bytecode will run wherever there's a JVM. 
But haXe (pronounced "hex") is more than just portable. It's a multiplatform 
language that can target diverse operating environments, ranging from native binaries 
to interpreters and virtual machines.

多くの言語は portable なコードを書くのに使えます。
C コンパイラーは事実上あらゆるCPUアーキテクチャーで利用できますし、
Java のバイトコードはJVMがあるところならどこででも実行可能です。
しかし haXe は単に portable というものを越えています。

Developers can write programs in haXe, then compile them into object code, JavaScript, 
PHP, Flash/ActionScript, or NekoVM bytecode today; additional modules for outputting 
C# and Java are in the works. Complementing the core language is the haXe standard 
library, which functions identically on every target, plus target-specific libraries 
to expose the unique features of each platform.


Experimental programming language No. 10: Chapel

In the world of high-performance computing, few names loom larger than Cray. It should 
come as no surprise, then, that Chapel, Cray's first original programming language, 
was designed with supercomputing and clustering in mind.


Source URL (retrieved on 2012-01-04 07:49AM):

■_ 12

プログラマーのための課題十二個 (でいいのかな?)

12 resolutions for programmers

12 resolutions for programmers

It's important for programmers to challenge themselves.
プログラマーにとって、challenge themselves することは重要です。

Creative and technical stagnation is the only alternative.

In the spirit of the new year, I've compiled twelve month-sized resolutions.

Each month is an annually renewable technical or personal challenge:

    Go analog.
    Stay healthy.
    Embrace the uncomfortable.
    Learn a new programming language.
    Learn more mathematics.
    Focus on security.
    Back up your data.
    Learn more theory.
    Engage the arts and humanities.
    Learn new software.
    Complete a personal project.

Read on for my suggestions.

Update: You might want to consider this article in conjunction with what every computer
science major should know.

Go analog

Programmers obsess over the discrete and the digital well past the point of 
diminishing returns.

Thus, small investments in the analog yield comparatively large gains.

Here's a starter list of analog activities to try, each of which takes about a month of
dedicated effort to transition out of the novice (and into the seasoned beginner) stage:

    Martial arts.


Learn a new programming language

Programming languages rise and fall.

Programmers that only know one language will restrict their problem-solving abilities and
their career prospects.

言語をひとつだけしか知らないプログラマーは自分の問題解決能力と自分のキャリアの prospects を

Spend a full month absorbing a new language or a new language paradigm.

Write a modest program in it.

Here are a few less mainstream languages to learn:
学ぶべき、less mainstream な言語をいくつか挙げてみました


If you're out of programming languages to learn, implement one.


Learn more mathematics

At its heart, computer science is a mathematical discipline.

Good mathematicians make good programmers.

Do not let your mathematical faculty wither.

Consider an annual one-month brush-up on one of these topics:

    Discrete mathematics.
    Abstract algebra.
    Number theory.
    Category theory.
    Order theory.


Complete a personal project

If you spend all day writing code for someone else, remember why you became a programmer by
writing a program for yourself.

Spend a month each year on a project of your choosing.

Bring the nucleus of that project to fruition.

Open source it and release it to the world.

■_ 7


7 programming languages on the rise

7 programming languages on the rise
By Peter Wayner
Created 2010-10-25 02:00AM


While the following seven niche languages offer features that can't be found in the 
dominant languages, many rely on the dominant languages to exist. Some run on top of 
the Java Virtual Machine, essentially taking advantage of the Java team's engineering. 
And when Microsoft built C#, it explicitly aimed to make the virtual machine open to 
other languages. That detail may help make deployment easier, but it doesn't matter 
much to the programmer at creation time.

Either way, these seven languages are quickly gaining converts in the enterprise. 
Perhaps it's time to start investigating their merits.

Programming languages on the rise: Python

There seems to be two sorts of people who love Python [7]: those who hate brackets, and
scientists. The former helped create the language by building a version of Perl [8] 
that is easier to read and not as chock-full of opening and closing brackets as a C 
descendant. Fast-forward several years, and the solution was good enough to be the 
first language available on Google's AppEngine [9] -- a clear indication Python has 
the kind of structure that makes it easy to scale in the cloud, one of the biggest 
challenges for enterprise-grade computing.

Python を愛好する人たちには二種類あるようです。
ブラケットを憎む人たちと、科学者 (scientists) です。


Programming languages on the rise: Ruby

Some may argue that Ruby and Python are hardly "niche" languages, but the 
truth is, from an enterprise perspective, they remain promising tools all too often 
pushed to the margin. That said, Ruby, or more precisely the combination of Ruby with 
the Rails framework known as Ruby on Rails, is becoming increasingly popular for 
prototyping. Its entrance into the enterprise came on the heels of the Web 2.0 
explosion, wherein many websites began as experiments in Ruby. 37signals [10] -- one 
of Ruby's many proponents -- actually uses Ruby to deploy code.

Ruby や Python は hardly に「ニッチ」な言語であると主張する人たちもいますが、


Programming languages on the rise: MATLAB

Built for mathematicians to solve systems of linear equations, MATLAB has found rising 
interest in the enterprise, thanks to the large volumes of data today's organizations 
need to analyze [12]. Many of the more sophisticated statistical techniques that match 
people with advertisements, songs, or Web pages depend upon the power of algorithms 
like those solved by MATLAB.


Programming languages on the rise: JavaScript

JavaScript is not an obscure language by any means. If anything, it may be the most 
compiled language on Earth, if only because every browser downloads the code and 
recompiles it every time someone loads a Web page. Despite this fact and the 
increasing dominance of AJAX-savvy Web pages, JavaScript is rarely thought of as a 
language that runs on the big iron.


Programming languages on the rise: R

Statistical analysis is being increasingly done in R these days, although some purists call
the language S, its original name. Tibco sells a commercial version called S-Plus [20].


R is another Swiss Army Knife of numerical and statistical routines for hacking 
through the big data sets [12] -- collections big enough that it might be better 
called a Swiss Army Machete. Lou Bajuk-Yorgan, senior director of product management 
for Tibco's Spotfire S-Plus, says its software is used by a number of clients who are 
studying how business or engineering projects might work or why they fail to work. 
Analyzing weather patterns to find the best places to build wind-powered generators is 
one example.

Programming languages on the rise: Erlang

Does your server need to respond to many different independent messages concurrently? 
Do you need to parcel these requests out to different cores or servers in various 
parts of the world? That's practically the definition of the hardest part of 
enterprise computing. Erlang [21], an open source language first created by scientists 
at Ericsson Computing Laboratory, excels at these tasks.


Programming languages on the rise: Cobol

It may not be fair to call Cobol a niche language as it was once the dominant language 
in the enterprise. Grace Murray Hopper, famous for finding the first bug in the early 
mainframes, helped create the language in 1959 and it's been enhanced hundreds of 
times since. Cobol jockeys today get to play with object-oriented extensions, 
self-modifying code, and practically every other gimmick.

かつてはエンタープライズ分野で支配的な言語であったこともある Cobol をニッチな言語
ことで有名な Grace Murray Hopper は 1959年にこの言語を作ることに注力し、
今日の Cobol jockeys はオブジェクト指向拡張や自己改変コード、
そのほかのあらゆる practically な gimmick でもってこの言語を操っています。


Programming languages on the rise: CUDA extensions As libraries for programming video 
cards to do massively parallel jobs, CUDA extensions are not technically a language; 
they're just extensions to C. Still, some enterprise programmers are beginning to 
unlock the massively parallel architectures normally devoted to rendering realistic 
blood splattering in alternative game worlds. Moreover, recoding loops for massive 
parallelism means rethinking many of the idioms from basic C or C++ programming, 
making CUDA extensions all the more valuable.


■_ 11


11 programming trends to watch

Published on InfoWorld (http://www.infoworld.com)

Home > Application Development > 11 programming trends to watch > 11 programming trends to watch

11 programming trends to watch
By Peter Wayner
Created 2011-11-28 03:00AM

Depending on your perspective and proximity to the bleeding edge, the world of 
programming evolves either too fast or too slow. But whether you're banging out Cobol 
or hacking Node.js, one fact remains clear: Programmers must keep an eye on the latest 
programming trends to remain competitive in ever-shifting job markets.


Programming trend No. 1: The JVM is not just for Java anymore
                         JVM はもはやJavaのためだけのものではない

A long time ago, Sun created Java and shared the virtual machine with the world. By 
the time Microsoft created C#, people recognized that the VM didn't have to be limited 
to one language. Anything that could be transformed into the byte code could use it.

その昔、Sun は Java を作り出し、そのバーチャルマシンを世界と共有しました。
Microsoft が C# を作り出したときに、人々は VM がひとつの言語に縛られるものではない

Now, it seems that everyone is building their language to do just that. Leave the job 
of building a virtual machine to Sun/Oracle, and concentrate your efforts on the 
syntactic bells and structural whistles, goes the mantra today.

現在、誰もが自分の言語を do just that のために作っているように思われます。
バーチャルマシンの構築を Sun/Oracle に任せてしまって
syntactic bells や structural whisles (構文的な鐘や構造的な笛?) に


Programming trend No. 2: JavaScript is not just for JavaScript anymore

The JVM isn't the only cross-platform solution open to all comers. JavaScript, the 
langauge your kid sister uses to add an alert box to her band's website, is not just 
for JavaScript coders any longer. The list of languages that cross-compile to run on 
the fancy, just-in-time JavaScript engines is even longer than the list that runs on 
the JVM.

JVM は all comers に開かれている唯一のクロスプラットフォームな solution ではありません。
yoor kid sister が彼女のバンドweb サイトに警告ボックスを追加するために
使っている言語であるJavaScirpt は、
もはや JavaScript coder たちのためだけのものではありません。


If that's not enough, there are experiments linking pretty much any language to 
JavaScript, including Ruby, Python, Lisp, Scheme, Haskell, and OCaml.

Programming trend No. 3: No code is an island

A friend once told me he was heading to the woods in Northern Michigan where his 
father and uncles built a cabin by themselves. It was theirs and theirs alone. They 
hauled the wood and the rock, and they could sit afterward and gaze at the sunset with 
deep pride in their accomplishment.

Writing a program used to be like this. Push the compile button, and after it churned, 
the code would take over your machine. Sure, it was interacting with the OS layer, but 
it was easier to point to a tangible thing that you built, just like that cabin. See 
that file with the EXE suffix? I built that one, mom.


Programming trend No. 4: Plantations everywhere

There's a dark side to these tightly integrated stacks of code: the walled garden.

The Internet began with the premise that there would be no gatekeepers. Every packet 
would be delivered to its destination, with our data free to wander. Alas, that 
promise is eroding, and not because the ISPs are increasingly turning to traffic 
shaping or deep packet inspection technologies.

These days, everyone seems to be retreating to walled gardens, where everything is 
safer and simpler. If you want to develop for the iPhone, you'll have to write code to 
Apple's vague specifications, then Apple -- and Apple alone -- will decide whether it 
will run on its machines. It's not up to you, the programmer, and it doesn't matter 
what the users say, either.

今日にあっては、すべての人があらゆるものがより安全でより単純である walled garden に
いるように思われます。もしあなたが iPhone 向けの開発をしたいというのなら、
Apple の vague specifications に対してコードを書かなければなり暗線。
そして Apple だけが自分たちのマシンであなたの書いたプログラムを実行するかどうかを


Programming trend No. 5: Openness retreats

For all the success of open source software, the ability to engage in pure tinkering 
is slipping away in many corners. The success of the iPhone has everyone looking to 
find ways to wall off the commons. Sure, the new car computer systems are built with 
Linux, but don't for a second think you'll be typing "make" and deploying to 
your car.


Programming trend No. 6: Bandwidth is no longer free

Web programmers have grown up believing bandwidth is free and getting ever faster. No 
need to worry about slow download times -- in a year, everyone's connection will be 
zippier, and the problem will disappear. Unfortunately, those days are over, thanks to 
more and more ISPs adding bandwidth caps and metering.


Programming trend No. 7: Energy is no longer free, either

The cost of keeping a computer plugged in has never been an issue. It never mattered 
how much energy your rack of servers sucked down because the colo just sent you a flat 
bill for each box.

No longer -- energy consumption is a big issue, whether you're programming for 
smartphones or the server farm. The biggest limitation of my Android phone is that it 
can drain its battery in 8 hours doing nothing but sitting there. Design an app that 
eats up battery power faster than GPS features do and watch downloads of your app 


Programming trend No. 8: Traditional education fades from relevance

Ask any project manager and they'll say there's not enough talent from top-tier 
computer science departments. They may go so far as to say they would hire a new CS 
major from a top school without reading the résumé. But ask this same desperate 
project manager about a middle-aged programmer with a degree from the same school, and 
they'll hesitate and start mumbling about getting back to you later.


Programming trend No. 9: Accuracy fades as scalability trumps all

Years ago, ACID ruled the database roost. The challenge was to build a bulletproof 
machine that always gave a correct and consistent answer when queried. Hurricanes, 
nuclear weapons, and errant janitors unplugging the rack could not scramble the 
database. The big customers were banks, hotels, and airlines, and they wanted to make 
sure bank accounts and reservations were consistent and correct.

Today, the industry is trying to find an easy way to store ephemera from our lives. 
From the places we visit to the toss-away comments between friends, the goal is to 
find a fast and efficient way to store endless tidbits from everyone on earth.


Programming trend No. 10: Real parallelism begins to get practical for all

Computer architects have been talking about machines with true parallel architectures 
for years, but the programmers in the trenches are just starting to get the tools that 
make it possible.

The parallelism is appearing in two prominent areas: multinode databases and Hadoop 
jobs. Some mix the two.


Programming trend No. 11: GPUs trump CPUs

Was it only a few years ago that the CPU manufacturers created the chips that fetched 
the most money? Those days are fading fast as the graphics processors are now the most 
lustworthy. It's easy to find kids who will spend $300 on their entire computer and 
operating system, then $600 on a new video card to really make it scream.


Source URL (retrieved on 2012-01-04 07:49AM):

■_ 10



Good Ideas, Through the Looking Glass | Lambda the Ultimate





1/4 22時からの番組で観たいなーとおもったやつ。 歴史秘話ヒストリア 100分 de 名著 TOKYO MX * 「プリズナーNO.6」 あと、NHK BSプレミアムでやってたやつ。

英語の論文なんかでよくある2カラム構成のドキュメントだと、 100% 表示では字が小さくて読めたものじゃないし、といって拡大すると 左カラムの上→左カラムの下→右カラムの上→右カラムの下 という感じで読み進めないとならなくて、ちとめんどー。 iPad で解決するんだろか。

一般企業も真似したいギークの7つの仕掛け - Nothing ventured, nothing gained. Martin Fowler's Bliki in Japanese - 朝会のパターン:立ってるだけじゃないよ

■_ 問題


Less Than Dot - Blog - Collection Of Puzzles For Programmers

Collection Of Puzzles For Programmers
by SQLDenis on Mar 02, 2009 in categories Ethics & IT

Did you know that we have a nice collection of puzzles here on less than dot? Some are 
harder than others so there is something for everyone. You can pic any language you 
want, you will see that there are solutions in Ruby, Python, Visual Basic, SQL, 
JavaScript, C++ and other.

Here is a partial list of what we have

©2008 - 2012 LessThanDot, LLC



まーた入力過多でまとまりがつかなくなってしまった○| ̄|_



1/5 追加

1/6 追加



映画を観てきました。 …が感想を詳しく書こうとするとネタバレしなければならなくなるのでどうしたものか。 アクションは良かったと思います。 一点だけ、終盤で飛葉がサブマシンガンをハリウッド映画でよく見られるように 横にして撃ってたシーンがあったのは気になりました(細かいな、おい)。 ストーリーは全体の構成としては悪くないと思うんですけど、 (ぴー)とか(ぴー)とか(ぴー)はちょっとなあ。 この辺は細かいことのようでいて、 結構世界観(ってこれは誤用の方か)に関わってくるんじゃないかなあ。 各メンバー、特に名前の変わってる人物はどうしても原作のそれと対比したくなるんですが 悪くなかったと思います。 というか時間が限られているのでそれほど掘り下げていけなかった?

これは面白そう New project: wrappi: an API for Linux | Richard WM Jones

新宿に行く用があったのでついでにCOMIC ZIN に行って買った。 COMIC ZIN 通信販売/商品詳細 チョコレート・アップル

■_ Free Pascal 2.6.0 での新機能

Modula-2 でごにょごにょしたい…

FPC New Features 2.6.0 - Lazarus wiki

FPC New Features 2.6.0


    1 About this page
    2 All systems
        2.1 Language
            2.1.1 Better support for Delphi-compatible classes
            2.1.2 Advanced record syntax
            2.1.3 Enumerators in records
            2.1.4 Support for class and record helpers
            2.1.5 Generic records, arrays and procedural types
            2.1.6 Scoped enumerations
            2.1.7 Custom deprecated messages
            2.1.8 Support for the Objective-Pascal dialect
            2.1.9 Constref parameter modifier
            2.1.10 Basic ISO Standard Pascal support
            2.1.11 Support for nested procedure variables
            2.1.12 Support for non-local goto's
            2.1.13 Support for &-escaping of keywords
            2.1.14 Support for univ parameters in MacPas mode
            2.1.15 CExtended floating point type
            2.1.16 SAR intrinsics
            2.1.17 ROL/ROR intrinsics
            2.1.18 Bitscan intrinsics
            2.1.19 Boolean16, Boolean32 and Boolean64 types
    3 ARM systems
        3.1 Support for VFPv2 and VFPv3
        3.2 Support for Thumb-2
    4 IA32/i386 systems
        4.1 Support for the iPhoneSim target
    5 See also

そしてreddit から

Free Pascal Compiler 2.6.0 has been released and adds many post-Delphi 7 language features and adds or improves the support for various platforms. : programming

Generics? Lambdas?

I'm going back indoors until this is settled.

Free pascal has had generics since 2.2, 2.6 has nested procedures, not closures, but 
can be used for similar limited functionality.


The very fact that nested procedure capture context that is destroyed when outer procedure
is finished makes me sad.

The fact that documentation lists that as invalid code makes me think that no error is 
issued in this case and program just goes wild.

Please, someone, tell me I'm wrong...

    The very fact that nested procedure capture context that is destroyed when outer procedure
    is finished makes me sad.

Well, it does have the benefit of not needing a GC. It's either GC, closure/region 
typing, or not returning pointers to stack.

Not to diss the effort but does anyone professionally develop in pascal anymore? I learned
to write software [well hack things, I wasn't very organized back then] in TP6/7 so I get
the intrigue about FPK. But I've never professionally written anything in it. Seems
embedded customers want C/asm/java.

I guess the most famouse application would be Skype for Windows. There are others as well.

I think he was referring to new applications rather than old ones. If you could just magically
change the language of your 1 million line project, a lot of highly paid COBOL developers
would be out of work.



■_ Rob Pike

Rob Pike talks about modern programers lack of imagination. : programming command center: Esmerelda's Imagination

■_ littler

ちっちゃい R らしい。

littler: a scripting front-end for GNU R

littler: a scripting front-end for GNU R

What ?

littler provides hash-bang (i.e. script starting with #!/some/path) capability for GNU R,
as well as simple command-line and piping use.

Why ?

GNU R, a language and environment for statistical computing and graphics, provides a 
wonderful system for 'programming with data' as well as interactive exploratory 
analysis, often involving graphs.

Sometimes, however, simple scripts are desired. While R can be used in batch mode, and 
while so-called 'here' documents can be crafted, a long-standing need for a scripting 
front-end has often been expressed by the R Community.

littler (pronounced 'little R' and written 'r') aims to fill this need.



>svn checkout http://littler.googlecode.com/svn/trunk/ littler-read-only
A    littler-read-only/littler.R
A    littler-read-only/AUTHORS
A    littler-read-only/configure.in
A    littler-read-only/cleanup
A    littler-read-only/ChangeLog
A    littler-read-only/.svnignore
A    littler-read-only/ANNOUNCEMENT
A    littler-read-only/autoloads.R
A    littler-read-only/README
A    littler-read-only/r.1
A    littler-read-only/tools
A    littler-read-only/tools/mkinstalldirs
A    littler-read-only/tools/depcomp
A    littler-read-only/tools/missing
A    littler-read-only/tools/config.guess
A    littler-read-only/tools/config.sub
A    littler-read-only/tools/install-sh
A    littler-read-only/littler.c
A    littler-read-only/tests
A    littler-read-only/tests/summary2.R
A    littler-read-only/tests/test1.R
A    littler-read-only/tests/timing.sh
A    littler-read-only/tests/timing2.sh
A    littler-read-only/tests/ts.R
A    littler-read-only/tests/dat.txt
A    littler-read-only/tests/test_longline.R
A    littler-read-only/tests/exitstatus.sh
A    littler-read-only/tests/shebang
A    littler-read-only/tests/longline.R
A    littler-read-only/tests/error.R
A    littler-read-only/tests/dotLast.r
A    littler-read-only/tests/summary.R
A    littler-read-only/tests/argParse.sh
A    littler-read-only/INSTALL
A    littler-read-only/COPYING
A    littler-read-only/Makefile.am
A    littler-read-only/littler.h.in
A    littler-read-only/ldflags.R
A    littler-read-only/bootstrap
A    littler-read-only/examples
A    littler-read-only/examples/update.r
A    littler-read-only/examples/fsizes.r
A    littler-read-only/examples/mph.r
A    littler-read-only/examples/install.r
A    littler-read-only/examples/install2.r
A    littler-read-only/examples/pace.r
 U   littler-read-only
Checked out revision 185.








■_ キーブレイク

"key break" でぐぐったらこういうページを発見

IBM InfoSphere Information Server, Version 8.5 Information Center



データは、ソートされていることを Transformer ステージが検出できるように、ジョブ内でソ
ートされている必要があります。 データがジョブに入力される前にソートされている場合、ダ
ミーの Sort ステージを組み込み、事前にソートされているデータのすべての列について、ステ
ージの「ソート・キー」プロパティーを「ソートしない (事前にソート済み)」にセットします。



(すなわち、この行がグループ内の最後の行である) 場合に TRUE を返します。この関数は、こ
の行が入力データの最後の行である場合も TRUE を返します。

    LastRowInGroup() を呼び出すことができます。


    指定された引数が 2 次またはその他のソート・キーである場合は、LastRowInGroup() は指定され
    た列の値が変わる直前、またはそれより高水準のキー列が変わる直前に TRUE を返します。 例えば、
    主ソート列が Col1、2 次ソート列が Col2 である場合は、LastRowInGroup() は Col2 の値が変わ
    る直前、または Col1 の値が変わる直前に TRUE を返します。 したがって、Col2 が変わる直前で
    はないが Col1 が変わる直前には TRUE を返します。Col1 は Col2 よりも上位のソート・キーだか


Key break detection

Key break detection

When your data is grouped on a column, and is sorted on this column, you can detect 
when you process the last row before the value in that column changes.

A key break can be detected on any column, as long as the input data has been sorted 
on that column. The data must be sorted in the job, so that the Transformer stage can 
detect that it is sorted. If the data is sorted before being input to the job, you can 
include a dummy Sort stage and set the stage's Sort Key property to Don't Sort 
(previously sorted) for every column on which the data was previously sorted.

You can use the following function to detect key breaks, and then process data accordingly:


You can call this function when processing an input row, and the function returns TRUE 
if the value in the named column changes after this row (that is, this row is the last 
row in a group). The function also returns TRUE if this row is the last row in the 
input data.

    If the input data is sorted by more than one column, then LastRowInGroup() can be called
    with any of those columns as its argument.

    If the argument specified is the primary sorted key, then the behavior is as described
    for a single column.

    If the argument specified is the secondary or other sorted key, then LastRowInGroup()
    returns TRUE if the value of the specified column is about to change, or if any of its
    higher level of key columns are about to change. For example, if the primary sorted
    column is Col1 and the secondary sorted column is Col2, then LastRowInGroup(Col2)
    returns true when either the value in Col2 is about to change, or the value in Col1 is
    about to change. Therefore it can return true when Col2 is not about to change, but Col1
    is, because Col1 is a higher level sorted key than Col2.


■_ 3912年


android - Why the current year in the date saved as 3912? - Stack Overflow

Why the current year in the date saved as 3912?

to get the current date and time

  final Calendar c = Calendar.getInstance();
  mYear = c.get(Calendar.YEAR);
  mMonth = c.get(Calendar.MONTH);
  mDay = c.get(Calendar.DAY_OF_MONTH);
  mHour = c.get(Calendar.HOUR_OF_DAY);
  mMinute = c.get(Calendar.MINUTE);

to create current date object

  Date toDate;

  Date endDate = toDate;

when printing endDate object I got

Mon Jan 01 13:11:00 GMT+03:00 3912

why ?

From Date.setYear(int) description: Sets the gregorian calendar year since 1900 for 
this Date object. Thus, 1900 + 2012 = 3912.

But calendar.get(Calendar.YEAR) returns exact year number 2012. So this inconsistency 
of API causes your issue. But anyway Date.setYear(int) is deprecated, thus, it is 
better to use Calendar object for date calculations.

then what I have to do ? – Adham Enaya

@AdhamEnaya You may subtract 1900 from year number: toDate.setYear(mYear - 1900).
But I better suggest to use Calendar object for date calculations.


■_ 問題

A short programming challenge for 2012. : programming

Mango12.com • View topic - Mango12 2012 Programming Competition

Post subject: Mango12 2012 Programming Competition
PostPosted: Sun Jan 01, 2012 9:19 am 

Task 課題
Compress a list of words into the shortest string that contains all the words.

Example 例


could become


The key is finding the words in the list that share as many letters as possible at the beginning or end.


A short programming challenge for 2012. : programming

This is equivalent to the traveling salesman problem.

Equivalent graph: each string is a node. Each weight is 1/comp where comp(a,b) is the maximum
overlap-ability between a and b, (comp("strbah", "bahfoo") = 3).

Is that the equivalence? The TSP I learned in school was

    Simple, not directed
    Integer weights, not Real
    Solution was a cycle, not a path

But your confidence tells me these differences do not matter.

That was the idea, though I think your weighting is slightly wrong. For example, if we 
have three words and we can choose between overlapping 5 and 5 characters, or 1 and 10 
characters, then obviously the latter option is better (11 total characters vs 10) yet 
1/5+1/5 < 1/1+1/10.

So this weighting does not work. One that does (I think), is using len(a) - comp(a,b) 
as the weight of the edge from a to b.

There is also an important preprocessing step: we should start by throwing out all 
words that are substrings of other words in the dictionary, otherwise we generate 
longer strings than strictly necessary (e.g. "abc", "b", would 
yield "abcb" instead of just "abc").

What if we set the weight between words a and b to be the length of their optimal 
combination? e.g. weight(strbah, bahfoo) = length(strbahfoo) = 9? This way the better 
we can mash them together, the shorter the word, the lower the weight.

I don't think this is exactly equivalent to the travelling salesman problem though, 
because we don't need to get back to our starting node. We just need to visit every 
node (word) once.

Edit: It seems there is a connection between the problems of finding a min-cost 
hamiltonian path and a min-cost hamiltonian cycle. So this may in fact be equivalent 
to the TSP.

    What if we set the weight between words a and b to be the length of their optimal
    combination? e.g. weight(strbah, bahfoo) = length(strbahfoo) = 9?

That's possible too, but then the total length of the tour does not correspond with 
the length of the solution, which is arguably slightly less nice. But as long as your 
weight for the edge (a,b) is of the form f(a) + g(b) - comp(a,b), it works (with 
comp(a,b) defined as the longest common suffix of a/prefix of b). In your case, 

The simplest weight is probably just -comp(a,b) though it may be slightly weird to 
have negative weights.

    I don't think this is exactly equivalent to the travelling salesman problem though, 
    because we don't need to get back to our starting node.

This is easily fixed by adding a single dummy word that doesn't combine with anything 
(e.g. "$"). It will be included once in the tour and can serve as the 
start/finish of the tour to reconstruct the minimal string.

With only four words it's reasonable to simply check every permutation:

from itertools import permutations

  def combine(a, b):
      for i in xrange(len(b), 0, -1):
          if a.endswith(b[:i]):
              return a + b[i:]
      return a + b

  def compress(wordlist):
      return sorted([reduce(combine, p) for p in permutations(wordlist)], key=len)[0]

  print compress(['testing', 'ginger', 'german', 'minutes'])

The problem would become quite interesting if it had to cope with more than a few 
words, as the exhaustive search strategy would not be feasible.

Using a dynamic programming approach, this can be reduced from an O(N!) algorithm to 
O(2^N), but that's still exponential and therefore only feasible for maybe ~25 words.

I'd recommend applying the usual heuristics for the travelling salesmen problem to get 
a good approximation of the optimal solution for a large number of words.





2012年もよろしくお願いします。 なんか良さそうな四字熟語の挨拶がないものか探したけれどみつからなかった。

昨日の2011年のまとめにちょっと名前を出した PowerShell と R の他にも APL とか J とか Prolog とか Forth とか これまで中途半端に手を出したことがあるものがあって…と書こうと思ったら 竹迫さんが APL の話題を出していた プログラミング言語Jの記法に馴染めなかったという人も、APLの記号ならわかりやすく理解できるかもしれません。 温故知新のAPL。ぜひ、みなさんも楽しいAPLライフをお過ごしください。 (TAKESAKO @ Yet another Cybozu Labs: プログラミング言語APLで謹賀新年Golf)

ってまあ「中途半端に手を出した」プログラミング言語は枚挙に暇がないってのが 正しいような気もします○| ̄|_


プログラミング言語でもう一つ。 例によって reddit やら hacker news やらで次のような プログラミング言語の進化の歴史をまとめたものが話題になってまして (どちらもpdf。拡大しないと内容が読めないと思います) http://www.levenez.com/lang/lang.pdf History of Programming Languages (pdf)

進化の系統で Forth だとか Prolog、SNOBOL なんてところが直接の祖先をもたず イキナリ登場してきているように見えるのですが (SNOBOL → Icon 系統は割と好きな言語だったり)、そのなかで ISWIM → awk という流れがあるのに気がつきました。 awkの(直接の)祖先でそんなんあったっけ? そもそもそんな名前のプログラミング言語聞いた覚えが、とぐぐると 日本語版うぃきぺにも項目が。

ISWIM - Wikipedia

ISWIM は、Peter J. Landin が考案し、1966年の Communications of the ACM 誌で発表した 
The Next 700 Programming Languages で初めて明らかにした抽象プログラミング言語(あるい
はプログラミング言語ファミリ)である。名称は "If you See What I Mean" の頭字


ISWIM は、ラムダ計算の関数型コアを命令型言語の糖衣構文で包んだものである。変更可能な変
数と代入と強力な制御機構として Landin の J 演算子を追加してある(J演算子は継続を可能と
したもので、Scheme の call/cc は J 演算子を簡略化したものである)。ラムダ計算に基づい
ているので、ISWIM は高階関数とスコープ変数を備えている。

ISWIM の操作的意味論は Landin のSECDマシンを使って定義されており、先行評価(eager 
evaluation)による値渡しを使っている。ISWIM の目標は、より数学的記法に近づけることであ
ったため、Landin は ALGOL の文の区切りであったセミコロンや begin と end によるブロック

ISWIM で特徴的な記法として、節(clause)の利用がある。ISWIM プログラムは、'where' 節を
は、CPLと共に最初に 'where' 節を使ったプログラミング言語の1つであった。



ISWIM - Wikipedia, the free encyclopedia

ISWIM is an abstract computer programming language (or a family of programming 
languages) devised by Peter J. Landin and first described in his article, The Next 700 
Programming Languages, published in the Communications of the ACM in 1966. The acronym 
stands for "If you See What I Mean" (also said to have stood for "I See 
What You Mean", but ISWYM was mistyped as ISWIM[citation needed]).

Although not implemented, it has proved very influential in the development of 
programming languages, especially functional programming languages such as SASL, 
Miranda, ML, Haskell and their successors.


ISWIM is an imperative language with a functional core, consisting of a syntactic 
sugaring of lambda calculus to which are added mutable variables and assignment and a 
powerful control mechanism — the J operator. Being based on lambda calculus ISWIM has 
higher order functions and lexically scoped variables.



    P. J. Landin The Next 700 Programming Languages. CACM 9(3):157–65, March 1966.
    Art Evans. PAL — a language designed for teaching programming linguistics. Proceedings ACM National Conference 1968.
    John C. Reynolds. GEDANKEN: a simple typeless language which permits functional data structures and co-routines. Argonne National Laboratory September 1969.
    Gordon Plotkin (1975). Call-by-Name, Call-by Value and the Lambda Calculus.
    Mirjana Ivanović, Zoran Budimac. A definition of an ISWIM-like language via Scheme. ACM SIGPLAN Notices, Volume 28, No. 4 April 1993.

This article was originally based on material from the Free On-line Dictionary of Computing, which is licensed under the GFDL.

↑のページにある The Next 700 Programming Languages のリンクの先には該当のドキュメントが無いみたいだけど 見覚えあるなあと思って自分の PC のHDD にある pdfファイルを探したらやっぱりあった。 どこで取ってきたんだっけ? ほとんど読んでいなかったのできんどるさんに放り込んだ。


ちょっと前(今回は2005年辺りのもの)のものが reddit で取り上げられて。 というパターン。 ちと気になったので辿ってみた。


さっき出したプログラミング言語の歴史の系統図についてもう一回 Programming Language History : programming

Programming Language History : programming

I think this history is wrong. Please look at the correct history.

Pretty nice, but seems to be missing a lot of newer languages, such as Agda or Scala

I was looking for Choreographer and Clipper too... Supporting dead languages is where the job stability is at.

It seems this graph gets Javascript wrong. In the political sense, it's probably 
correct. But it's not as though half a dozen teams collaborated to make Ruby so that 
can't be the sense they intended.

There ought to have been a line from Scheme and from Self to somewhere in Javascript's 
lineage. Brendan Eich, the creator of Javascript, has said as much.

Why does Java 7 branch off like that. Are they breaking backward compatibility (finally) ?

I wasn't aware of that

That is missing a few datasets, like ruby 1.9.3x


One Div Zero: A Brief, Incomplete, and Mostly Wrong History of Programming Languages

One Div Zero

An exploration of software development.
Thursday, May 7, 2009

A Brief, Incomplete, and Mostly Wrong History of Programming Languages

なーんか見覚えがあるなあと思ったらやっぱり翻訳している人がいた (自分もそのころどうこう書いてたような記憶がかすかに)。

不完全にしておよそ正しくないプログラミング言語小史 Functional Programming Memo: [Joke] Translation of "A Brief, Incomplete, and Mostly Wrong History of Programming Languages"

元記事の最後の方を見ると、2010年にも追加があるというのでんじゃあそこをと思ったら ↑の青木さんの方はしっかりこれも訳されてたw


    5/8/09 added BASIC, 1964
    5/8/09 Moved curly brace and angle bracket comment to footnotes
    5/8/09 corrected several punctuation and typographical errors
    5/8/09 removed bit about Odersky in hiding
    5/8/09 added Objective-C, 1986
    5/8/09 added Church and Turing
    4/9/10 added Ada (1983) and PHP(1995)

1983 - In honor of Ada Lovelace's ability to create programs that never ran, Jean Ichbiah and
the US Department of Defense create the Ada programming language. In spite of the lack of
evidence that any significant Ada program is ever completed historians believe Ada to be a
successful public works project that keeps several thousand roving defense contractors out of


1995 - At a neighborhood Italian restaurant Rasmus Lerdorf realizes that his plate of spaghetti
is an excellent model for understanding the World Wide Web and that web applications should mimic
their medium. On the back of his napkin he designs Programmable Hyperlinked Pasta (PHP). PHP
documentation remains on that napkin to this day.




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



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