ときどきの雑記帖 RE* (新南口)
カサブランカに愛を
生産性
アメリカン・ベースボール革命-データ・テクノロジーが野球の常識を変える- という本を読んでいたらここでもでてきた「生産性」。
近年では、データアナリストがはるか以前から非難してきた(そしてマネー・ボールのアスレチックスが避けていた) 送りバントや、非効率な盗塁といった生産性の低い戦略は好まれなくなっている。
(p.24)
つまり、攻撃側の観点から言った場合、得点に至る確率の高い(期待値の高い?)プレーを 「生産性の高い」プレーとしているということなのかしらん。
てんぞうちょうかいきょう
「転造跳開橋」。今週の(何曜日の放送かは忘れた)ピタゴラスイッチで出てきた。 実物もちょっと見てみたい😄
- 【ピタゴラ】番組内で紹介された可動橋【動画あり】 | 294ブログ
- ピタゴラスイッチの「そこで橋はかんがえた」に驚いた! - いいものいっぱい、厳選こそだて
- ピタゴラスイッチ「そこで橋は考えた」の可動橋をまとめてみたよ! - イケメン息子とぐうたら猫の成長見守りブログ
- LEGOで『跳ね橋』と『転造跳開橋』を作った。歯車で動く機械の面白さを紹介する - むにむに別館 | Yahoo! JAPAN クリエイターズプログラム
- 可動橋 - Wikipedia
割と以前から取り上げていたみたいだけど これまで見た記憶ないな(他の可動橋の放送回は見覚えがある)?🤔
bash Idioms
(洋書だけど)近刊でこんな本を見つけた。
Amazon では 6219JPYの値段がついていて、 最近のオライリーの原著はまあこんな感じの値段だよなあと思いつつ comの方のAmazon bash Idioms: Write Powerful, Flexible, Readable Shell Scripts: Amazon.com: Books で確認すると 49.99USD。 ふむう。
langinfo
wctypeとiswctypeのつづきから。
iswctype
wctypeとiswctypeについての マニュアルページを いくつか見ていたら FreeBSDのものでこんな記述を見つけた。
wctype() 関数は、要求されたワイド文字クラスを表すタイプ wctype_t の値を返して、 それは iswctype() への呼び出しの 2 番目の引数として使用することができます。
iswctype() 関数は wc が charclass によって表現された特性があるか、または charclass が 0 の時かつその時に限り 0 以外を返します。
iswctypeの方の後半がよくわからんな。と。 charclass(iswctypeの第二引数。要はwctypeで指定のものが見つからないときに返された値)が 0のときにiswctypeの戻り値が(wcの値によらず)0以外を返していいんだろうか?
ということで英文にあたるが
The wctype() function returns a value of type wctype_t which represents the requested wide character class and may be used as the second argument for calls to iswctype().
The iswctype() function returns non-zero if and only if wc has the property described by charclass, or charclass is zero.
if and only if をどう訳すのにもよるのだろうけど 誤訳というわけではなさそうだ>日本語マニュアル
さらに他のものも見てみると
_isctype, iswctype, _isctype_l, _iswctype_l | Microsoft Docs
_isctype and iswctype return a nonzero value if c has the property specified by desc in the current locale or 0 if it does not.
desc(iswctypeの第二引数)が0の場合については言及されていない。
ところでこんなことも書かれていて
c がEOF _isctype、_isctype_l 0 ~ 0xFFの範囲 (C を含む) の場合、この動作は未定義です。 デバッグ CRT ライブラリが使用され 、c がこれらの値の 1 つではない場合、関数はアサーションを生成します。
あー、これは…ということで英語表示に切り替えると
The behavior of _isctype and _isctype_l is undefined if c is not EOF or in the range 0 through 0xFF, inclusive. When a debug CRT library is used and c is not one of these values, the functions raise an assertion.
not
はin the range 0 through 0xFF にもかかる?
さらにIBMのもの
wctype() — 文字特性種別のハンドルの取得 - IBM Documentation
指定された特性名が無効の場合、wctype() 関数はゼロを戻します。 そうでない場合には、iswctype() の呼び出しに使用できる型 wctype_t の値を 戻します。
iswctype() — 文字プロパティーのテスト - IBM Documentation
iswctype() 関数は、ワイド文字 wc がプロパティー wc_prop を 持っているかどうかを判別します。 wc の値が WEOF でもなく、マルチバイト文字に対応するワイド文字の値でもない場合は、その振る舞いは予期できません。 wc_prop の値が無効な場合 (つまり、前の wctype() 関数呼び出しで取得されたものでない、 または wc_prop が後続の setlocale() 関数呼び出しによって無効になった場合)、その振る舞いは予期できません。
最後にopengroupのもの。
The iswctype() function shall determine whether the wide-character code wc has the character class charclass, returning true or false. The iswctype() function is defined on WEOF and wide-character codes corresponding to the valid character encodings in the current locale. If the wc argument is not in the domain of the function, the result is undefined. If the value of charclass is invalid (that is, not obtained by a call to wctype() or charclass is invalidated by a subsequent call to setlocale() that has affected category LC_CTYPE ) the result is unspecified.
result is unspecified
だそうな。
__localedata
前回の続きで。 __locale_data全体を見ると
/* Structure describing locale data in core for a category. */
struct __locale_data
{
const char *name;
const char *filedata; /* Region mapping the file data. */
off_t filesize; /* Size of the file (and the region). */
enum /* Flavor of storage used for those. */
{
ld_malloced, /* Both are malloc'd. */
ld_mapped, /* name is malloc'd, filedata mmap'd */
ld_archive /* Both point into mmap'd archive regions. */
} alloc;
/* This provides a slot for category-specific code to cache data computed
about this locale. That code can set a cleanup function to deallocate
the data. */
struct
{
void (*cleanup) (struct __locale_data *);
union
{
void *data;
struct lc_time_data *time;
const struct gconv_fcts *ctype;
};
} private;
unsigned int usage_count; /* Counter for users. */
int use_translit; /* Nonzero if the mb*towv*() and wc*tomb()
functions should use transliteration. */
unsigned int nstrings; /* Number of strings below. */
union locale_data_value
{
const uint32_t *wstr;
const char *string;
unsigned int word; /* Note endian issues vs 64-bit pointers. */
}
values __flexarr; /* Items, usually pointers into `filedata'. */
};
ちゃっちゃっとこういうのを表す図を描きたいのだけど 何を使うのがいいのかねえ…
という愚痴はさておき、このデータ構造を使った実際の例をひとつ (ja_JP.UTF8なものだともっとよかったのだろうけど)。
const struct __locale_data _nl_C_LC_CTYPE attribute_hidden =
{
_nl_C_name,
NULL, 0, 0, /* no file mapped */
{ NULL, }, /* no cached data */
UNDELETABLE,
1, /* Enable transliteration by default. */
NR_FIXED + NR_CLASSES + NR_MAPS,
{
/* _NL_CTYPE_CLASS */
{ .string = _nl_C_LC_CTYPE_class },
/* _NL_CTYPE_TOUPPER */
{ .string = (const char *) _nl_C_LC_CTYPE_toupper },
/* _NL_CTYPE_GAP1 */
{ .string = NULL },
/* _NL_CTYPE_TOLOWER */
{ .string = (const char *) _nl_C_LC_CTYPE_tolower },
/* _NL_CTYPE_GAP2 */
{ .string = NULL },
/* _NL_CTYPE_CLASS32 */
{ .string = _nl_C_LC_CTYPE_class32 },
/* _NL_CTYPE_GAP3 */
{ .string = NULL },
/* _NL_CTYPE_GAP4 */
{ .string = NULL },
/* _NL_CTYPE_GAP5 */
{ .string = NULL },
/* _NL_CTYPE_GAP6 */
{ .string = NULL },
/* _NL_CTYPE_CLASS_NAMES */
{ .string = "upper\0" "lower\0" "alpha\0" "digit\0" "xdigit\0" "space\0"
"print\0" "graph\0" "blank\0" "cntrl\0" "punct\0" "alnum\0" },
...省略
/* NR_CLASSES wctype_tables */
{ .string = (const char *) _nl_C_LC_CTYPE_class_upper.header },
{ .string = (const char *) _nl_C_LC_CTYPE_class_lower.header },
{ .string = (const char *) _nl_C_LC_CTYPE_class_alpha.header },
{ .string = (const char *) _nl_C_LC_CTYPE_class_digit.header },
{ .string = (const char *) _nl_C_LC_CTYPE_class_xdigit.header },
{ .string = (const char *) _nl_C_LC_CTYPE_class_space.header },
{ .string = (const char *) _nl_C_LC_CTYPE_class_print.header },
{ .string = (const char *) _nl_C_LC_CTYPE_class_graph.header },
{ .string = (const char *) _nl_C_LC_CTYPE_class_blank.header },
{ .string = (const char *) _nl_C_LC_CTYPE_class_cntrl.header },
{ .string = (const char *) _nl_C_LC_CTYPE_class_punct.header },
{ .string = (const char *) _nl_C_LC_CTYPE_class_alnum.header },
/* NR_MAPS wctrans_tables */
{ .string = (const char *) _nl_C_LC_CTYPE_map_toupper.header },
{ .string = (const char *) _nl_C_LC_CTYPE_map_tolower.header }
}
};
なるほど、こうやってテーブル情報(たぶん)のポインターを並べていると。
次は_nl_C_LC_CTYPE_class_upper
などがどんな定義で、どんな内容なのかを追いかけることにしよう。
今日は何の日
【3F/#映画】
— 書泉グランデ | 神保町 (@shosengnd) February 13, 2022
本日2/13は突如出現した謎の怪星ゴラスが
地球に最接近した日だそうです
(映画「#妖星ゴラス」)
地球の約六千倍の引力を持ち、他の惑星を
吸収し太陽系に接近しつつある妖星ゴラスに対し
地球の軌道を変えて衝突を回避しようとする
人類の戦いが描かれています#神保町 #書泉グランデ pic.twitter.com/224jX4bOLI