ときどきの雑記帖 RE* (新南口)
アンインストール
(4) 石川智晶 LIVE 2015年1月「アンインストール」 - YouTube
「インストール」とは
南武線車内で見かける「番組」のお話。 ニュースやCM、しずえさんのアレ以外にも Yostar提供の新番組「CREATIVE TRAIN」がJR東日本トレインチャンネルなどで開始に こういうのが流れていたりする。 その番組では週替わりで色々なクリエイターが 「あなたにとっての『インストール』とは?」 という問いに答えているのだけど、 その回答を見ても「インストール」という言葉をどういう意味で使っているのがどうにもわからなかった。
ということでググったら前述のリンクが見つかって、そこに答えもあったのだけど
「CREATIVE TRAIN」はJR東日本をはじめとする首都圏10路線に搭載された車内サイネージである「トレインチャンネル」で放送される新番組で、 毎週各業界で活躍するクリエイターが登場し、クリエイターとしてインスピレーションを取り入れるための行為を広く “インストール”という言葉に置き換え、自身のクリエイティブに関する考え方やエピソードを語るインタビュー番組です。 また「トレインチャンネル」では放送しきれなかったエピソードをYouTubeの公式チャンネルでも配信しています。
んーーー?
確かにそういった質問に対する回答だったように思うけど、それを「インストール」と呼ぶ……
わからん 🤔
- Yostar、JR東日本「トレインチャンネル」で新番組「CREATIVE TRAIN」を放送開始 『アズレン』や『アークナイツ』のキャラがナビゲーターに | Social Game Info
- (1) CREATIVE TRAIN【公式】さん (@CreativeTrainPR) / Twitter
今週のしずえさん
ハンコの原料に使われている食材とは?
Benevolent dictator for life
村上さんの名前があったから問題ないだろうと思って読んでたら「あれ?」 と思うような部分があったので書き残す。
以下、日本語部分の引用は 「Python」の弱点やそのとらえ方–生みの親、グイド・ヴァンロッサム氏が語る - (page 2) - ZDNet Japan から。英語部分の引用は Programming languages: Why Python hasn’t taken off on mobile, or in the browser - according to its creator | ZDNet から。
かつて「優しい終身の独裁者」(BDFL)と呼ばれていたvan Rossum氏は2020年11月よりMicrosoftの ディスティングイッシュト・エンジニアとして勤務し、CPythonコミュニティーに対する同社の貢献を支援している。 CPythonコミュニティーは、van Rossum氏が生み出したPythonを機械学習(ML)やデータサイエンスの興隆という波に乗せ、 今日最も人気が高いプログラミング言語の1つに押し上げた功績を有している。
Van Rossum, the former “Benevolent dictator for life” of Python has, since November, been working at Microsoft as a distinguished engineer, helping the software giant give back to the Python community who have helped make his creation one of the most popular programming languages today, thanks to the rise of machine learning and data science.
Benevolent dictator for life をどう訳すかは…まあスルーしておいてですね。
- for lifeの意味・使い方・読み方 | Weblio英和辞書
- dictatorの意味・使い方・読み方|英辞郎 on the WEB
- perpetuusの意味・使い方|英辞郎 on the WEB
- Dictator perpetuo - Wikipedia
Python community who have helped make ~と来ているので、 CPythonコミュニティーは(略)功績を有している となるのはおかしい気がする。
この who、関係代名詞なのは間違いないとしてその先行詞はなんだろう? とりあえず直前に来ているものと考えると (Python) community だけど これはwhoで受けていいものなんだろうか?(「人物」ではない。よねえ)
ということで調べてみると、whoで受けても問題ないし、なんだったら 書き手の意図によってはそうした方が良いものらしい。
- Community Who / Community That | WordReference Forums
- (4) If the text says a community (of people), would the following word be “who” or “which”? - Quora
そうすると二文にわけた後半は
Python community have helped make his creation one of the most popular programming languages today, thanks to the rise of machine learning and data science.
となるのだけど、
- python comunityはhelpした(現在完了)
- his creation (he→Guido、his creation→python) をone of the most popular programming languages today にするのを
- the rise of machine learning and data science に thanks to して
だから、やっぱり「功績を有する」はおかしい気がするなあ。
Pythonの優しい終身の独裁者は科学技術計算とMLの分野でライバルになるであろうJuliaについても言及した。 この言語は人気を集めつつあるが、PythonほどにはMLやデータ科学のライブラリーが充実していない。
Python’s benevolent dictator also had some words for would-be rival language in scientific computing and machine learning, Julia, a language that is gaining in popularity but doesn’t have the wealth of machine-learning and data-science libraries Python has.
開発者らはJuliaがニッチな言語にとどまり続けるか、Pythonに匹敵するほどの言語になり得るのかについて思いを巡らせている。 van Rossum氏は、マサチューセッツ工科大学(MIT)が生み出したJuliaについて、「Pythonとよく似た目標に向けた興味深い取り組み」だと述べた。
Developers wonder whether Julia will remain a niche language or if it has the potential to reach the heights of Python. Van Rossum said Julia, which emerged from MIT, was an “interesting take on something Python-like.”
“interesting take on something Python-like.” = 「Pythonとよく似た目標に向けた興味深い取り組み」 になるかなあ?
「(Juliaは)Pythonと細かいところでとてもよく似ているが、配列のすべての添字が1から始まり、 範囲の終端が除外されずに内包される点に気付いた時にうわぁ!と感じるはずだ」(van Rossum氏)
“[Julia] has enough details that are very similar to Python that when you realize, oh, but all the indexing is one ranges are inclusive instead of exclusive, you think arrgggh!”
all the indexing is one ranges are inclusive instead of exclusive はどう転んでも 配列のすべての添字が1から始まり、範囲の終端が除外されずに内包される とはならないような。one と rangesの間にカンマも何もないし
二番目のthatの先行詞がわからない(関係代名詞じゃない。ってことはないよねえ)。 直前のPythonだとすると意味が取れない(気がする)。
とりあえずそこは脇に置いて、 rangesがinclusiveだexclusiveだってのはつまりこういうことだよね? (例示したスクリプト片は PythonistaのためのJulia入門 - Qiitaから)
for i in range(10):
print i
for n = 0:9
println(n)
end
で、これを日本語で(わかりやすく)書き表すにはどうする? (投げっぱなしジャーマン (投げっぱなしジャーマンとは (ナゲッパナシジャーマンとは) [単語記事] - ニコニコ大百科))
同氏は「JuliaとPythonを同じ日にコーディングしたいと考える人などいないはずだ」と冗談を述べ、 Pythonと比較するとJuliaは「ニッチな言語」だと続けた。
“Nobody should ever try to code in Julia and in Python on the same day,” he joked, describing it as a “niche language” compared to Python.
describing it as a を単に「だと続けた」としちゃうとニュアンスが変わってしまうような。
しかし同氏は「そういったニッチな領域で作業する場合、JuliaはコンパイラーによってPythonでは望めないほどの最適化が達成されるため、 素晴らしい言語だと言える」と付け加えた。ただ、「一方、それ以外の領域で作業する場合、Juliaはずっと制約の多い言語だ。 Juliaでウェブサーバーを開発して、さまざまなことを実行したいと考える人など誰もいないと私は考えている」とも述べた。 なお、van Rossum氏はRustのファンでもあるが、Googleが生み出したGoが最近の新言語すべてのなかで最も「Pythonっぽい」と考えているという。
But he added: “If you’re in that niche, it is superior because the compiler optimizes your code in a way that Python probably never will. On the other hand it is much more limited in other areas and I wouldn’t expect that anybody ever is going to write a web server in Julia and get a lot of mileage out of it.” Van Rossum is also fan of Rust but he reckons Google-created Go is the most “Pythonic” of all the new languages.
原文では一塊にダブルクォーテーションで囲まれているのに、それを二つに分けて 「~付け加えた。」「ただ、」「とも述べた」というのをくっつけるのはどうなんだろう?
I wouldn’t expect that ~ が「私は考えている」は、ありか?
目についた(最初に引っかかった)のは rangeのinclusive/exclusiveだったのに グダグダ書いてしまった。
追記
ブログ: Pythonの生みの親グイド・ヴァンロッサムが考えるRust、Go、Julia、TypeScriptとは
で、同様の発言(の翻訳)を見かけた。
GoとJulia:「私は今でも、Goも非常に面白い言語だと思っています。新しい言語の中では、Goが最もPythonらしいというか、 少なくとも汎用的な新しい言語だと思います。他にもJuliaがあります。これは、Pythonのようなものを取り入れていて面白いものになっています。 Pythonによく似た細部を持っているので、『ああ、でもインデックスはすべて1ベースで、範囲は排他的ではなく包括的だ』と気づいた時には、 『アーッ!』と思うでしょう。同じ日にJuliaとPythonでコーディングしようとする人はいないでしょうね。
「私の理解では、Juliaはどちらかというとニッチな言語で、そのニッチがあるからと言うなら、 Pythonではおそらく決して行わないような方法でコンパイラがコードを最適化してくれるので、Juliaの方が優れていると思います。 一方、他の分野ではかなり制限されていて、誰もがJuliaでWebサーバを書いて、多くの利益を得ようとは思わないでしょう。 5分後にはHacker Newsに反例が掲載されると思いますが。」
こちらの翻訳でも
“[Julia] has enough details that are very similar to Python that when you realize, oh, but all the indexing is one ranges are inclusive instead of exclusive, you think arrgggh!”
であろう部分が(こっちの翻訳記事の原文は(まだ)追いかけてないのよ)、
インデックスはすべて1ベースで、
となってるけど、all the indexing is one ranges… をそうは訳せないんじゃないかなあ。
んが2対1で分が悪いので改めて考えてみよう…
- . What is the meaning of “Zero based indexing/one based indexing” in multiport switch? - MATLAB Answers - MATLAB Central
- Zero-based numbering - Wikipedia
- 1-based indexing
- 0-Based Indexing: A Julia How-To. Introduction | by Soumitra Shewale | Analytics Vidhya | Medium
- Why do Julia arrays use 1-based indexing? · Issue #558 · JuliaLang/julia
ん、この翻訳記事の元はslashdotで、さらにその元はYouTube(にある動画)なのか。
- What Python Creator Guido van Rossum Thinks of Rust, Go, Julia, and TypeScript - Slashdot
- (4) Q&A with Guido van Rossum, Inventor of Python - YouTube
glob(そのn+4)
v7unix/v7/usr/src/cmd/sh at master · v7unix/v7unix
コマンドラインからコマンドを実行するときの関数呼び出しの 大雑把なフローはこんな感じ(再掲)で
exfile
+ execute
| + cmd
| + list
| + term
| + word
| + item
+ getarg
| + split
| + expand
|
+ execa
+ execs
上記のcmd にぶら下がっているもののうちword以外は 同じファイル(cmd.c)にあり、関数の直前にはそれぞれ構文定義のようなコメントが ついている。
具体的には以下の通り。
v7unix/cmd.c at ed636a47207476db76d53b7869447889dee3bbad ・ v7unix/v7unix
/*
* cmd
* empty
* list
* list & [ cmd ]
* list [ ; cmd ]
*/
/*
* list
* term
* list && term
* list || term
*/
/*
* term
* item
* item |^ term
*/
/*
* item
*
* ( cmd ) [ < in ] [ > out ]
* word word* [ < in ] [ > out ]
* if ... then ... else ... fi
* for ... while ... do ... done
* case ... in ... esac
* begin ... end
*/
まあなんとなく、どういった「構文」(文法)なのか見当はつきますね。
cmd
ということでexcuteから呼び出されるcmdを追いかける
/*
* cmd
* empty
* list
* list & [ cmd ]
* list [ ; cmd ]
*/
TREPTR cmd(sym,flg)
REG INT sym;
INT flg;
{
REG TREPTR i, e;
i = list(flg);
IF wdval==NL
THEN IF flg&NLFLG
THEN wdval=';'; chkpr(NL);
FI
ELIF i==0 ANDF (flg&MTFLG)==0
THEN synbad();
FI
SWITCH wdval IN
case '&':
IF i
THEN i = makefork(FINT|FPRS|FAMP, i);
ELSE synbad();
FI
case ';':
IF e=cmd(sym,flg|MTFLG)
THEN i=makelist(TLST, i, e);
FI
break;
case EOFSYM:
IF sym==NL
THEN break;
FI
default:
IF sym
THEN chksym(sym);
FI
ENDSW
return(i);
}
makelist
makeforkはとりあえず後回しにして、makelist という関数はこんな感じ (ソースコード上ではすぐそばにあるから、気になる向きはどうぞご自分で >makefork)。
LOCAL TREPTR makelist(type,i,r)
INT type;
TREPTR i, r;
{
REG TREPTR t;
IF i==0 ORF r==0
THEN synbad();
ELSE t = getstak(LSTTYPE);
t->lsttyp = type;
t->lstlef = i; t->lstrit = r;
FI
return(t);
}
まあ取り立てて解説の必要はないと思うけど…って、あれ? 🤔
構造体の内容がどういったものなのかを確かめてみると
v7unix/mode.h at ed636a47207476db76d53b7869447889dee3bbad · v7unix/v7unix
STRUCT trenod *TREPTR;
v7unix/mode.h at ed636a47207476db76d53b7869447889dee3bbad · v7unix/v7unix
* this node is a proforma for those that follow */
struct trenod {
INT tretyp;
IOPTR treio;
};
コードで参照していたlstlef とか lstrit ってナニモノなのかだけど、 ここでANSI以前のCでの構造体のメンバー名の仕様を思い出してみよう。
ということで makelist で使っているメンバー名から探してみるとこれが見つかる。
v7unix/mode.h at ed636a47207476db76d53b7869447889dee3bbad · v7unix/v7unix
struct lstnod {
INT lsttyp;
TREPTR lstlef;
TREPTR lstrit;
};
ふむ。これでもまだポインターに整数値を入れてることになるけどまあそれは
(ここでThe Ten Commandments for C Programmers (Annotated Edition)
を参照…と思ったがこれに該当する項目はなかった?)。
メンバーの数が合わない(trenod 2個、lstnod 3個)けどいいのかこれ。
それと名前に関してだけど、
- lsttyp → list type
- lstlef → list leaf
だとして、lstritはなんだろう? 「リテラル」は「literal」だしなあ。
(飽きつつあるが)まだまだもうちょっと続く
glob(そのn+4.1)
zsh と bashのことも忘れていませんよ。 というほどのメモ(こっちに話題が移るのはいつのことやら)。
zsh/Src/glob.c
/* Main entry point to the globbing code for filename globbing. *
* np points to a node in the list which will be expanded *
* into a series of nodes. */
/**/
void
zglob(LinkList list, LinkNode np, int nountok)
{
/* The actual processing takes place here: matches go into *
* matchbuf. This is the only top-level call to scanner(). */
scanner(q, shortcircuit);
cond.c:50: zglob(args, firstnode(args), 0);
exec.c:3196: zglob(args, firstnode(args), 0);
glob.c:1182:zglob(LinkList list, LinkNode np, int nountok)
subst.c:481: * - PREFORK_NO_UNTOK: pass into zglob() a flag saying do not untokenise.
subst.c:501: zglob(list, node, (flags & PREFORK_NO_UNTOK) != 0);
bash/eval.c
/* Read and execute commands until EOF is reached. This assumes that
the input source has already been initialized. */
int
reader_loop ()
/* Call the YACC-generated parser and return the status of the parse.
Input is read from the current input stream (bash_input). yyparse
leaves the parsed command in the global variable GLOBAL_COMMAND.
This is where PROMPT_COMMAND is executed. */
int
parse_command ()
bash/perse.y
inputunit: simple_list simple_list_terminator
{
/* Case of regular command. Discard the error
safety net,and return the command just parsed. */
global_command = $1;
}
/* A simple_list is a list that contains no significant newlines
and no leading or trailing newlines. Newlines are allowed
only following operators, where they are not significant.
This is what an inputunit consists of. */
simple_list: simple_list1
{
$$ = $1;
if (need_here_doc)
gather_here_documents ();
if ((parser_state & PST_CMDSUBST) && current_token == shell_eof_token)
{
global_command = $1;
bash/lib/glob/glob.h
extern int glob_pattern_p __P((const char *));
extern char **glob_vector __P((char *, char *, int));
extern char **glob_filename __P((char *, int));
extern int extglob_pattern_p __P((const char *));
bash/lib/glob/glob.c
確率
6つのサイコロを10000回投げたときの5の目がでる確率をPythonでもとめる - Qiita
問題文の意味がよく取れなかったのだけど、 6つのサイコロを一度に投げて一つでも5が出る確率 ということで良いんだろうか?
とりあえず
☓ 9998: 4 3 1 2 3 6 確率1.0049009801960391
○ 9999: 4 4 3 1 2 5 確率1.0049004900490048
○ 10000: 5 6 2 6 6 1 確率1.0049
確率が1.0を超えているのはおかしな気が。 各回の試行で5があったかなかったかの回数を数えているのではなく 投げた6つのうち5が出たサイコロの数を足しこんでいるからか?
>python
Python 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> [5,5,4,3,5].count(5)
3
話を戻してこの確率の計算は
1 - (5/6)6
で良いのかな。
>>> (5/6)**6
0.3348979766803842
>>> 1 - (5/6)**6
0.6651020233196159
>>>
ということでちょっといじったスクリプト。
#6つのサイコロを10000回投げたときの5の目がでる確率をPythonでもとめる - Qiita
#https://qiita.com/osorezugoing/items/5852bd45ad3ce3ccc44f
#にあったスクリプトを改変
import random
def sai_no_me():
return random.randint(1,6)
count5_total=0
for i in range(1,10001):
saikoro1 = sai_no_me()
saikoro2 = sai_no_me()
saikoro3 = sai_no_me()
saikoro4 = sai_no_me()
saikoro5 = sai_no_me()
saikoro6 = sai_no_me()
result = [saikoro1, saikoro2, saikoro3, saikoro4, saikoro5, saikoro6]
count5 = result.count(5)
is_exist='☓'
if count5 > 0:
is_exist = '○'
count5_total += 1
kakuritsu = count5_total/i
print('{} {}: {} {} {} {} {} {} 確率{}'.format(is_exist, i, saikoro1,saikoro2,saikoro3,saikoro4,saikoro5,saikoro6,kakuritsu))
確率がそれっぽい数字にはなったか?
今記事を見直したらちゃんと指摘のコメントがついてたけど せっかくだから(ry
(4) のりこえるの歌/真心ブラザーズ - YouTube https://www.youtube.com/watch?v=KRe3AabDNrI