Android Market でオライリーを買いまくる
Android MarketでもO'Reilly の本が買えたみたいだ。iTunes なくていいね、高いし。
例えば、Programming Scalaは
http://itunes.apple.com/jp/app/programming-scala/id331172188?mt=8
で800円だが
http://jp.androlib.com/android.application.com-aldiko-android-oreilly-programmingscala-xBEq.aspx
では$4.99で84円/ドルのレートだと420円くらいか
あとは、epubでいい感じに
スネーク
http://d.hatena.ne.jp/yashigani_w/20090702/1246536852
を見かけたので、print_state を書き換えてみた
typedef enum { START, MOUTH, EYE_A, BODY_A_1, CENTER, BODY_A_2, TAIL_A, EYE_B, BODY_B, TAIL_B, SNAKE_A, SNAKE_B, ERROR, } snake_status; struct snake_status_entry { snake_status snake_code; const char *status_text; }; const struct snake_status_entry snake_status_table[] = { {START, "START"}, {MOUTH, "MOUTH"}, {EYE_A, "EYE_A"}, {BODY_A_1, "BODY_A_1"}, {CENTER, "CENTER"}, {BODY_A_2, "BODY_A_2"}, {TAIL_A, "TAIL_A"}, {EYE_B, "EYE_B"}, {BODY_B, "BODY_B"}, {TAIL_B, "TAIL_B"}, {SNAKE_A, "SNAKE_A"}, {SNAKE_B, "SNAKE_B"}, {ERROR, "ERROR"}, }; static int snake_status_comparison(const void *key, const void *member) { snake_status status; const struct snake_status_entry *table_entry; status = *(const snake_status *)key; table_entry = (const struct snake_status_entry *)member; return (status - table_entry->snake_code); } void print_state(snake_status state){ struct snake_status_entry *snake; snake = bsearch(&state, &snake_status_table, sizeof(snake_status_table) / sizeof(*snake_status_table), sizeof(*snake_status_table), snake_status_comparison); if (snake == NULL) { exit(EXIT_FAILURE); } printf("state:: %s ", snake->status_text); }
ひさしぶりの日記
http://blog.s21g.com/articles/1344 と id:isano:20090308:1236483960 に触発されてJavaScriptで書いてみました。
function getcombination(n) { return (function (n, i, result) { if(n >= i) { result.push([i, n-i]); return arguments.callee(n, i+1, result); } return result; })(n, 0, []); } print(getcombination(10));