ときどきの雑記帖 RE* (新南口)
玄人のひとりごと
ツクツクボウシ
今夏初遭遇
The Self-Taught Computer Scientist
タイミングが良いというかちょうど原著を某大型書店で見かけて 買おうか悩んでいたところだった(結局買ってない)。
『独学コンピューターサイエンティスト』 The Self-Taught Computer Scientist の紹介 — 清水川Web
つれづれなる数学日記
前回引用した つれづれなる数学日記 4/2の記述 をp5.jsのスクリプトで書いてみた。
function setup() {
createCanvas(800, 600);
colorMode(HSB, 360, 100, 100, 100);
}
function draw() {
background('#000000');
const A = [400, 50];
const B = [ 50, 550];
const C = [750, 550];
noFill();
stroke('#ffffff');
beginShape();
vertex(A[0], A[1]);
vertex(B[0], B[1]);
vertex(C[0], C[1]);
endShape(CLOSE);
const P = [A, B, C];
let m = [400, 300];
fill('#ffffff');
for (let n=0; n<2000; n+=1) {
circle(m[0], m[1], 3);
const t = floor(random(0, 3));
m = [floor((P[t][0]+m[0])/2), floor((P[t][1]+m[1])/2)];
}
noLoop();
}
実行結果を見ると、なるほど確かにシェルピンスキーのギャスケットだった。
awk
goawk
いくつか興味深いissueが。
- Incorrect parsing of complex ++ expressions · Issue #79 · benhoyt/goawk
- Dynamically changing RS · Issue #143 · benhoyt/goawk
- Reconsider handling of bytes vs characters in length() and similar functions · Issue #35 · benhoyt/goawk
gawk
何気なしにgawkのメーリングリストをチェックしてたら 次のバージョン(5.2.0)のベータテストの案内が出ているのに気がついた。
Beta release for gawk 5.2.0 now available
This note is to announce the BETA release of GNU Awk 5.2.0.
It is available from:
http://www.skeeve.com/gawk/gawk-5.1.65.tar.gz
This is a major release.
The important part of the NEWS file is below.
で、主な変更点など。
Changes from 5.1.x to 5.2.0
---------------------------
*****************************************************************************
* MPFR mode (the -M option) is now ON PAROLE. This feature is now being *
* supported by a volunteer in the development team and not by the primary *
* maintainer. If this situation changes, then the feature will be removed. *
* For more information see https://...... *
*****************************************************************************
1. Infrastructure upgrades: Libtool 2.4.7.
2. Numeric scalars now compare in the same way as C for the relational
operators. Comparison order for sorting has not changed. This only
makes a difference when comparing Infinity and NaN values with
regular numbers; it should not be noticeable most of the time.
3. If the AWK_HASH environment variable is set to "fnv1a" gawk will
use the FNV1-A hash function for associative arrays.
4. The CMake infrastructure has been removed. In the five years it was in
the tree, nobody used it, and it was not updated.
5. There is now a new function, mkbool(), that creates Boolean-typed
values. These values *are* numbers, but they are also tagged as
Boolean. This is mainly for use with data exchange to/from languages
or environments that support real Boolean values. See the manual
for details.
6. As BWK awk has supported interval expressions since 2019, they are
now enabled even if --traditional is supplied. The -r/--re-interval option
remains, but it does nothing.
7. The rwarray extension has two new functions, writeall() and readall(),
for saving / restoring all of gawk's variables and arrays.
8. The new `gawkbug' script should be used for reporting bugs.
9. The manual page (doc/gawk.1) has been considerably reduced in size.
Wherever possible, details were replaced with references to the online
copy of the manual.
10. Gawk now supports Terence Kelly's "persistent malloc" (pma),
allowing gawk to preserve its variables, arrays and user-defined
functions between runs. THIS IS AN EXPERIMENTAL FEATURE!
For more information, see the manual. A new pm-gawk.1 man page
is included, as is a separate user manual that focuses on the feature.
11. Support for OS/2 has been removed. It was not being actively
maintained.
12. Similarly, support for DJGPP has been removed. It also was not
being actively maintained.
13. VAX/VMS is no longer supported, as it can no longer be tested.
The files for it remain in the distribution but will be removed
eventually.
14. Some subtle issues with untyped array elements being passed to
functions have been fixed.
15. There have been numerous minor code cleanups and bug fixes. See the
ChangeLog for details.
Changes from 5.1.1 to 5.1.x
---------------------------
1. Infrastructure upgrades: Automake 1.16.5, Texinfo 6.8.
2. The rwarray extension now supports writing and reading GMP and
MPFR values. As a result, a bug in the API code was fixed.
3のハッシュと10のpersistent mallocの話はちょっと気になるな。
FNV1-A hash
で検索するといろいろ見つかるけどこの辺を見ておくか
Persistent Memory Allocationはこの辺が見つかったけど実質同じ?
- Persistent Memory Allocation: Leverage to move a world of software: Queue: Vol 20, No 2
- Persistent Memory Allocation - ACM Queue
- https://www.usenix.org/system/files/login/articles/login_winter19_08_kelly.pdf
from Qiita
awkを使ったデータ加工 - Qiita という記事で
# 年月を抜く
cat $lv3d/SalesResults |
awk 'NR >1{print $0}' | ##先頭行を抜く
awk '$6 !="_"{print $0}'|
awk '$9 !="_"{print $0}'|
awk '$12 !="_"{print $0}'|
awk '$15 !="_"{print $0}'|
awk '$18 !="_"{print $0}'|
awk '$21 !="_"{print $0}'|
awk '$24 !="_"{print $0}'|
awk '$27 !="_"{print $0}'|
awk '$30 !="_"{print $0}'|
awk '$33 !="_"{print $0}'|
awk '$36 !="_"{print $0}'|
awk '$39 !="_"{print $0}'|
awk '$42 !="_"{print $0}'|
awk '$45 !="_"{print $0}'|
awk '$48 !="_"{print $0}'|
awk '$51 !="_"{print $0}'|
awk '$54 !="_"{print $0}'|
awk '$57 !="_"{print $0}'|
awk '$60 !="_"{print $0}'|
awk '$63 !="_"{print $0}'|
awk '$66 !="_"{print $0}'|
awk '$69 !="_"{print $0}'|
awk '$72 !="_"{print $0}'|
awk '$75 !="_"{print $0}'|
awk 'NR ==1{print $0}' | ##先頭行
cat > $tmp-mas
というのがあったのだけど(これで全体の1/3くらい)、
最後のawkの呼び出しでexit
してないから二行目以降も延々空読みすることに…
要するにチェック対象のフィールドがすべてそろった(内容が_
でない)レコード
を見つけられればいいのだから
20数段のパイプじゃなくてひとつのawkスクリプトで片付けられるんじゃなかろうか。
第6フィールドから第75フィールドまで二つおきにフィールドの中身を見て
内容が_
だったら即座に次のレコード(行)の処理に移り(next
を使う)、
_
が最後まで出てこなかったらそのレコード
が「当たり」なので
レコードの内容を出力して終わり(exit
)。
後ろ2/3はよくわからん部分があるので触れないけど 他に書きようがありそうではある。
まあ「外野」がどうこういう問題でもないか。
80376
今日のi386系列CPUはすべて石器時代の16bitモードで起動するようになっており、32/64bitを使うには起動後に切り替える必要がある。しかし最初から32ビットモードで起動する「幻のCPU」があった。Intel 80376 (1989年) である。しかしこれはページングをサポートしてなかった。https://t.co/Y9Zf80ovQ4
— 新山祐介 (Yusuke Shinyama) (@mootastic) August 16, 2022
The Intel 80376 – a Legacy-Free i386 (with a Twist!) – pagetable.com
元記事の最後の部分が面白かった😄
Sounds like the perfect CPU? Well, here comes the catch: The 80376 doesn’t do paging. CR2 and CR3 don’t exist (it is undocumented whether accessing them causes an exception), CR0.PG is hardcoded to 0 (page 8) and the #PF exception does not exist (page 17). A man can dream though… a man can dream.
Coffee with Brian Kernighan
Brian Kernighanインタビュー「AWKの開発について」
— 新山祐介 (Yusuke Shinyama) (@mootastic) August 17, 2022
AWKはもともと自然言語処理(!)のために開発されたSEDの拡張として生まれ、正規表現エンジンはAhoが書いたegrepから取り込んだ。AWKのアルファベットがこの順序になったのは、彼らがいたベル研の部屋がこの順序だったため。https://t.co/gcChs630S7
追伸: Kernighanはいまだにroffを使っているらしい。24分あたりのくだりは笑える:
— 新山祐介 (Yusuke Shinyama) (@mootastic) August 17, 2022
「しかしroffにはまだUnicodeサポートがなくてね...」
「LaTeXを使ったらいいじゃないの?」
「…」
彼はあまりTeXが好きじゃないらしい。激しく同意である。
カーニハン大先生へのインタビューって つい最近にもあったよな(それをこのタイミングで)? と思っていたら別のインタビューでしたの巻。
YouTubeでKernighan
を検索するとこれを含めていくつか見つかる。
Kernighan - YouTube
CppCastへのゲスト出演は半年前だった。
CppCast: Unix and C History with Brian Kernighan
FORTRAN Compiler on IBM 704
忘れているわけでも 飽きて放り投げたわけでもないんですけど以下略。