ときどきの雑記帖 RE* (新南口)
時代おくれ
裏ドラ
裏ドラは14枚の各々の牌が1/34の確率で抽選されるものとすれば(手に有る場合は表示にならないなどを無視すると)平均0.411枚
— AzaleaClive (@AzaleaClive) May 3, 2022
さて、1/34となるかどうかなので二項分布であるとみなすと、99%信頼区間は0.409<x<0.450
なので、概ね単純平均値どおりに収束って感じか・・・。 https://t.co/qw6Eqz3dSw
1/34ってどこから(出てきた数字)? と思ってしまったけど
- 数牌 3種類*9
- 字牌 7種類
なので27+7で34か。
0.411(枚)は
(1/34)*14
$ ruby -e 'puts (1.0/34)*14'
0.4117647058823529
かな。
ツイートにある「裏ドラ的中率」が あがったときに裏ドラが乗っかったものだとすると 14枚中に一枚も裏ドラが含まれない確率は
(33/34)14
なので、少なくとも一枚は裏ドラが含まれる確率は (ものすごく単純に考えて)
1 - (33/34)14
$ ruby -e 'puts 1-(33.0/34)**14'
0.34159924578673706
と言いたいところだけど、 14枚すべてが違うアガリ形はないはずなので (国士無双でもアタマはある)、 13で計算した方が良い?
$ ruby -e 'puts 1-(33.0/34)**13'
0.3216477077802746
Turbo Vision
Turbo Vision 懐かしい。 公開はしなかったけど、当時(いつ?)何本かTurbo Visionを使ったプログラム作ったなあ。
ボーランドのTurbo Pascalなどで使われていた、テキストターミナルでGUIを実現するためのフレームワークTurbo Visionの現代環境向け移植版 / https://t.co/kg5UoUQM8a
— ABA (@abagames) May 3, 2022
をみると、さすがにDOS限定と言うことはなくて複数のプラットフォームで使えると。
A modern port of Turbo Vision 2.0, the classical framework for text-based user interfaces. Now cross-platform and with Unicode support.
The original goals of this project were:
- Making Turbo Vision work on Linux by altering the legacy codebase as little as possible.
- Keeping it functional on DOS/Windows.
- Being as compatible as possible at the source code level with old Turbo Vision applications. This led me to implement some of the Borland C++ RTL functions, as explained below.
ライセンスはこちら。
tvision/COPYRIGHT at master · magiblot/tvision
Ada in GCC
前回書いた GCCのAdaで書かれた部分の話 のつづき。
PC にgcc 5.1.0のソースコードが展開されていたのを見つけたので adaディレクトリにどのくらいのAdaで書かれたものがあるのかを調べてみた。
まずはファイルの数
*.adb
913 個のファイル 30,118,340 バイト
*.ads
1045 個のファイル 9,430,281 バイト
リポジトリをみて「たくさんあるな」とは思ったけど 想像以上だなこの数。
そして「行数」(の合計)はというと
$ wc -l *.adb *.ads
1084547 total
$ wc -l *.ads
206593 total
$ wc -l *.adb
877954 total
元記事の「60万行」とはだいぶ違う数字だけど、 バージョンも違うだろうし コメント行を含まない数字かもしれないということで。
glob bash 5
shell_glob_filename
の#else /* !USE_POSIX_GLOB_LIBRARY */
以降の部分を改めて見てみる。
#else /* !USE_POSIX_GLOB_LIBRARY */
char *temp, **results;
int gflags, quoted_pattern;
noglob_dot_filenames = glob_dot_filenames == 0;
temp = quote_string_for_globbing (pathname, QGLOB_FILENAME|qflags);
gflags = glob_star ? GX_GLOBSTAR : 0;
results = glob_filename (temp, gflags);
free (temp);
if (results && ((GLOB_FAILED (results)) == 0))
{
if (should_ignore_glob_matches ())
ignore_glob_matches (results);
if (results && results[0])
strvec_sort (results, 1); /* posix sort */
else
{
FREE (results);
results = (char **)&glob_error_return;
}
}
return (results);
#endif /* !USE_POSIX_GLOB_LIBRARY */
}
glob_filename (temp, gflags)
から返された
results
に対して
ignore_glob_matches (results);
のようなことをしているけど、これは
GLOBIGNORE で一時的に*(ワイルドカード)のglob 展開を止める。 - それマグで!
に書かれているようなことを行うためなので、
今回の目的(ってなんだっけ)からは
ちょっと外れるけど
簡単に追いかけると
まず使用する構造体として
struct ignorevar {
char *varname; /* FIGNORE, GLOBIGNORE, or EXECIGNORE */
struct ign *ignores; /* Store the ignore strings here */
int num_ignores; /* How many are there? */
char *last_ignoreval; /* Last value of variable - cached for speed */
sh_iv_item_func_t *item_func; /* Called when each item is parsed from $`varname' */
};
というものがあり、事前の準備のために以下のような関数がある。
/* Set up to ignore some glob matches because the value of GLOBIGNORE
has changed. If GLOBIGNORE is being unset, we also need to disable
the globbing of filenames beginning with a `.'. */
void
setup_glob_ignore (name)
char *name;
{
char *v;
v = get_string_value (name);
setup_ignore_patterns (&globignore);
if (globignore.num_ignores)
glob_dot_filenames = 1;
else if (v == 0)
glob_dot_filenames = 0;
}
void
setup_ignore_patterns (ivp)
struct ignorevar *ivp;
{
int numitems, maxitems, ptr;
char *colon_bit, *this_ignoreval;
struct ign *p;
this_ignoreval = get_string_value (ivp->varname);
/* If nothing has changed then just exit now. */
if ((this_ignoreval && ivp->last_ignoreval && STREQ (this_ignoreval, ivp->last_ignoreval)) ||
(!this_ignoreval && !ivp->last_ignoreval))
return;
/* Oops. The ignore variable has changed. Re-parse it. */
ivp->num_ignores = 0;
if (ivp->ignores)
{
for (p = ivp->ignores; p->val; p++)
free(p->val);
free (ivp->ignores);
ivp->ignores = (struct ign *)NULL;
}
if (ivp->last_ignoreval)
{
free (ivp->last_ignoreval);
ivp->last_ignoreval = (char *)NULL;
}
if (this_ignoreval == 0 || *this_ignoreval == '\0')
return;
ivp->last_ignoreval = savestring (this_ignoreval);
numitems = maxitems = ptr = 0;
#if 0
while (colon_bit = extract_colon_unit (this_ignoreval, &ptr))
#else
while (colon_bit = split_ignorespec (this_ignoreval, &ptr))
#endif
{
if (numitems + 1 >= maxitems)
{
maxitems += 10;
ivp->ignores = (struct ign *)xrealloc (ivp->ignores, maxitems * sizeof (struct ign));
}
ivp->ignores[numitems].val = colon_bit;
ivp->ignores[numitems].len = strlen (colon_bit);
ivp->ignores[numitems].flags = 0;
if (ivp->item_func)
(*ivp->item_func) (&ivp->ignores[numitems]);
numitems++;
}
ivp->ignores[numitems].val = (char *)NULL;
ivp->num_ignores = numitems;
}
このコードを見ると 無視するパターンを複数与えられるようだけど、 面倒なので(ry
- bash/pathexp.c at f3a35a2d601a55f337f8ca02a541f8c033682247 · bminor/bash
- Filename Expansion (Bash Reference Manual)
Go, Perl, LISP
https://t.co/BYuaCAUgGc
— こうじ (@mhkoji) May 4, 2022
ハッカーになろうのおすすめ言語、いつの間にかJavaの代わりにGoがおすすめされてたのか。
へー、と思って How To Become A Hacker を見に行くと、結構変更履歴があった。
Revision History
Revision 1.52 03 Jasnuary 2020 esr
Go makes a place as a plausible learning language, displacing Java.
Revision 1.51 06 October 2017 esr
Link to "Things Every Hacker Once Knew." Mention USB-stick distros. Many updated translation links.
Revision 1.50 19 July 2015 esr
Added link to "Let's Go Larval".
Revision 1.49 21 November 2014 esr
Added link to "How To Learn Hacking".
Revision 1.48 19 June 2014 esr
freshmeat/freecode is dead, alas.
Revision 1.47 20 May 2014 esr
Fix up various stale links. Join a hackerspace!
Revision 1.46 25 Sep 2013 esr
Add micropatronage explanation and gittip link. Why you should not ask me for advice on how to get started.
Revision 1.45 12 May 2013 esr
Open Solaris isn't, and Unity screwed the pooch.
Revision 1.44 20 May 2012 esr
Updated the critique of Java.
Revision 1.43 07 Feb 2011 esr
Python passed Perl in popularity in 2010.
Revision 1.42 22 Oct 2010 esr
Added "Historical note".
Revision 1.40 3 Nov 2008 esr
Link fixes.
Revision 1.39 14 Aug 2008 esr
Link fixes.
Revision 1.38 8 Jan 2008 esr
Deprecate Java as a language to learn early.
Revision 1.37 4 Oct 2007 esr
Recommend Ubuntu as a Unix distro for newbies.
Goに対する言及があるのはこの辺。
1. Learn how to program.
略
I used to recommend Java as a good language to learn early, but this critique has changed my mind (search for “The Pitfalls of Java as a First Programming Language” within it). A hacker cannot, as they devastatingly put it “approach problem-solving like a plumber in a hardware store”; you have to know what the components actually do. Now I think it is probably best to learn C and Lisp first, then Java.
略
A better alternative to Java is to learn Go. This relatively new language is pretty easy to move to from Python, and learning it give you a serious leg up on the possible next step, which is learning C. Additionally, one of the unknowns about the next few years is to what extent Go might actually displace C as a systems-programming language. There is a possible future in which that happens over much of C’s traditional range.
んでperl (こっちは以前からのそのままということなんだろうけど)。
Other languages of particular importance to hackers include Perl and LISP. Perl is worth learning for practical reasons; it’s very widely used for active web pages and system administration, so that even if you never write Perl you should learn to read it. Many people use Perl in the way I suggest you should use Python, to avoid C programming on jobs that don’t require C’s machine efficiency. You will need to be able to understand their code.
Perlはもういいんじゃないかな。
— こうじ (@mhkoji) May 4, 2022
確かに今it's very widely used for active web pages and system administration
と言われても疑問符つくよなあ。
LISP is worth learning for a different reason — the profound enlightenment experience you will have when you finally get it. That experience will make you a better programmer for the rest of your days, even if you never actually use LISP itself a lot. (You can get some beginning experience with LISP fairly easily by writing and modifying editing modes for the Emacs text editor, or Script-Fu plugins for the GIMP.)
ふと気になって日本語訳は? と調べたらちゃんと改訂されていた
How To Become A Hacker: Japanese
Revision 1.52-1.51 2020.01.03 esr 学習用言語としてGoがよくなったのでJavaを置きかえた。いくつかのリンク、USBメモリ版ディストリビューションの話。リンク更新。(翻訳改訂 2020.02.25)
Hugo メモ
0.98.0 とminorがひとつあがったけど 今回は0.97.xとは違って落ち着いているっぽい? (まだ0.96.0を使っている)
Release v0.98.0 · gohugoio/hugo
今回の新機能
This release is mostly some important upgrades of Hugo’s core dependencies, but we have also added crypto.FNV32a template function, which produces 32-bit unsigned integer hashes from a string. We have already many hash functions, but none of them produces an integer, which can be useful, e.g.:
{{ $mystring := "Hugo" }} {{ $colors := slice "orange" "blue" "green" "steel" "hotpink" }} {{ $hash := (crypto.FNV32a $mystring) }} {{ $i := mod $hash (len $colors) }} {{ $color := index $colors $i }}
ふむ。
休暇は終わりぬ
聞いてもない事を教えてくるボンドルド#メイドインアビス pic.twitter.com/J7u4Zds0Fb
— ドゥビドゥバ (@gerogero00001) May 6, 2022