1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

R リテラルなしquit

Last updated at Posted at 2020-02-17

「No」と言えない人がワークスペースを保存しないで終了したいときに

Raclett3さんの文字列と数値と真理値のリテラルに親を殺されたPythonプログラミングに触発されてやってみました
リテラルについてはあまりなじみがありませんでしたが、一応使わない形にできていると思います
他にもいろいろな方法があると思いますが一例として見ていただければ

参考:

コード

q(rawToChar(as.raw(as.hexmode(as.numeric(c(paste0(length(length({})), length(length({})), length({})), paste0(length(length({})), length(length({})), length(length({})))))))))

コピペすればRが終了します

解説

0と1の取得

{}でNULLを取得し、length({})length(length({}))でnumericの0と1を取得

110と111を含むベクトルを作成

paste0でcharacterの110と111を作成し、ベクトルにしてから、as.numericでnumericに変換

110と111を16進数に変換

as.hexmodeで110と111を6eと6fに変換

バイトコードに変換し"no"を取得

as.rawで上記のベクトルをバイトコードに変換してから、rawToCharでcharacterの"no"に変換

"no"をqに渡して終了

上記の"no"をqに第一引数として渡して、save="no"として実行させると終了する

備考

文字列・数値リテラルを使わずに Hello Worldの方法に倣ってやった方が簡単かもしれません

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?