Quine ブログ シリーズの前回の冒険では、独自の Quine とイントロンを記述する方法を検討しました。今日は、QuineRelay とは何か、そして Intron を活用して QuineRelay を作成する方法を見ていきます。
それぞれが異なる言語で書かれた一連のプログラムを想像してください。このサークル内の各プログラムには、シーケンス内の次のプログラムのソース コードを出力するという 1 つの目的があります。最後のプログラムは、最初のプログラムのソース コードを出力してループを閉じます。
本質的に、QuineRelay は、次のような n 個の異なる言語で作られた n 個のプログラムのセットです:
- 各プログラムは次のプログラムのソースを出力します。
- 最後のプログラムは最初のプログラムのソースを出力します。 ここで循環リンクリストについて考えてみましょう。最後の例は驚くべきものです!
概念をよりよく理解するためにいくつかの例を見てみましょう。
2次リレー
この 2 次 QuineRelay は、Python プログラムを出力し、元の JavaScript プログラムを出力する JavaScript プログラムを備えています。それは自己複製のダイナミックなデュオです。
JavaScript → Python ⥀
JavaScript: オンラインで試してみましょう!
Python: オンラインで試してみましょう!
3次リレー
3 次 QuineRelay を使用すると、物事はさらに面白くなります。これは Haskell プログラムで始まり、Python プログラムが出力され、Python プログラムが Ruby プログラムを出力し、最後に Ruby プログラムは元の Haskell プログラムにループバックします。
Haskell → Python2 → Ruby ⥀
Haskell: オンラインで試してみましょう!
Python2: オンラインで試してみましょう!
ルビー: オンラインで試してみましょう!
4次リレー
これは 4 次 QuineRelay です: Ruby → Java → C# → Python ⥀
GitHub
文化を超えて、共通の象徴性がいくつかあります。そのうちの 1 つはウロボロスで、エジプト、ギリシャ、ローマ、ヒンズー教、シベリア、北欧、アフリカ、南米の神話に言及しています。ウロボロスは、自分の尾を食い荒らす蛇や龍を描いた古代のシンボルで、創造と破壊の永遠のサイクルを表しています。
北欧神話では、ヨルムンガンドはロキと巨人娘アングルボザの中間子である巨大な蛇です。オーディンはヨルムンガンドをミズガルズ (人間の領域) を取り囲む海に投げ込み、そこで蛇は非常に巨大になり、世界を取り囲み、自らの尾を掴みました。ミッドガルド(地球)を取り囲んでいるため、世界蛇・ウロボロスと呼ばれています。ヨルムンガンドが尻尾を放つのは、ラグナロク(世界最後の戦い)の始まりの兆しの一つです
クワインリレーはこの象徴性を非常にうまく体現しており、サイクル内の各プログラムが次のプログラムを生み出し、最後には生まれ変わるだけであるため、ウロボロス プログラムという愛称が付けられています。
128次ウロボロスリレー
席に座ってください。こちらは128次のウロボロス・クワインリレーです。はい、そのとおりです。 128!!!
Ruby → Rust → Scala → ... (他 120) ... → Python → R → Ratfor → rc → REXX ⥀
GitHub
独自の QuineRelay を作成する
以前に書いた Python イントロンを開始して、それを 2 次 QuineRelay に変えてみましょう。
Python Intron: オンラインで試してみましょう!
リーリー
コード 部分をイントロンに簡単に挿入できるようになりました。次の形式のプログラムを作成します:
パイソン:
リーリー
データ として機能するだけです。データとイントロンの名前をそれぞれ d1 と d2 に変更しましょう。
パイソン:
リーリー
パイソン:
リーリー
d1 の内容が 3 行目の単なるコピーであることはすでにわかっています。しかし、d2 の内容はまだありません。
たとえば、JavaScript を使用して QuineRelay を作成したいとします。同様のイントロンをJSで書いてみましょう
JavaScript:
リーリー
さて、上記の JS イントロンの 3 行目は、私たちが望んでいた兄弟プログラムの
です!
お互いのコード
を相手のイントロンとして貼り付けます。
注記。引用符の不一致を避けるために、js に d1 + '' を追加する必要があります
Python: Try it online!
d1 = "print('d1 =', repr(d1)); print('d2 =', repr(d2)); print(d2)" d2 = "console.log(`d1 = ${JSON.stringify(d1)}`); console.log(`d2 = ${JSON.stringify(d2)}`); console.log(d1 + '');" print('d1 =', repr(d1)); print('d2 =', repr(d2)); print(d2)
JavaScript: Try it online!
d1 = "print('d1 =', repr(d1)); print('d2 =', repr(d2)); print(d2)" d2 = "console.log(`d1 = ${JSON.stringify(d1)}`); console.log(`d2 = ${JSON.stringify(d2)}`); console.log(d1 + '');" console.log(`d1 = ${JSON.stringify(d1)}`); console.log(`d2 = ${JSON.stringify(d2)}`); console.log(d1 + '');
There you go. It's a proper 2nd order QuineRelay! A Python program, that prints a JavaScript program, that prints the original Python program back in a cycle.
Creating a QuineRelay is an exercise in creative coding and understanding how different languages represent and manipulate strings. It involves weaving together introns from various programs, each containing the code to replicate its next neighbour.
At its core, an nth-order relay is a game of n clever ways to escape quotes across n programming languages.
Stay tuned for the next post on MultiQuine!
Sources and references:
- Ouroboros programs, wiki page.
- A Third Order Quine in Three Languages, blog by sigfpe.
- Chain Quine, GitHub repo by Ibragimov Ruslan.
- 128 Quine Relay, GitHub repo by Yusuke Endoh.
- QuineRelay: Birth of the Quine serpent, self-referencing blog where a word in each n-order example hyperlinks to the next, cyclically. (May not work in dev.to; checkout the canonical blog)
- Jörmungandr, wiki page.
- Ouroboros, wiki page.
- Art of Code, talk by Dylan Beattie
以上がQuineRelay: クワインの蛇の誕生の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

PythonArraysSupportVariousoperations:1)SlicingExtractsSubsets、2)Appending/ExtendingAdddesements、3)inSertingSelementSatspecificpositions、4)remvingingDeletesements、5)sorting/verversingsorder、and6)listenionsionsionsionsionscreatenewlistsebasedexistin

numpyarraysAressertialentionsionceivationsefirication-efficientnumericalcomputations andDatamanipulation.theyarecrucialindatascience、mashineelearning、物理学、エンジニアリング、および促進可能性への適用性、scaledatiencyを効率的に、forexample、infinancialanalyyy

UseanArray.ArrayOverAlistinPythonは、Performance-criticalCode.1)homogeneousdata:araysavememorywithpedelements.2)Performance-criticalcode:Araysofterbetterbetterfornumerumerumericaleperations.3)interf

いいえ、notallistoperationSaresuptedbyarrays、andviceversa.1)arraysdonotsupportdynamicoperationslikeappendorintorintorinsertizizing、whosimpactsporformance.2)リスト

toaccesselementsinapythonlist、useindexing、negativeindexing、slicing、oriteration.1)indexingstartsat0.2)negativeindexingAcsesess.3)slicingextractStions.4)reterationSuseSuseSuseSuseSeSeS forLoopseCheckLentlentlentlentlentlentlenttodExeror。

Arraysinpython、特にvianumpy、arecrucialinscientificComputing fortheirefficienty andversitility.1)彼らは、fornumericaloperations、data analysis、andmachinelearning.2)numpy'simplementation incensuresfasteroperationsthanpasteroperations.3)arayableminablecickick

Pyenv、Venv、およびAnacondaを使用して、さまざまなPythonバージョンを管理できます。 1)Pyenvを使用して、複数のPythonバージョンを管理します。Pyenvをインストールし、グローバルバージョンとローカルバージョンを設定します。 2)VENVを使用して仮想環境を作成して、プロジェクトの依存関係を分離します。 3)Anacondaを使用して、データサイエンスプロジェクトでPythonバージョンを管理します。 4)システムレベルのタスク用にシステムPythonを保持します。これらのツールと戦略を通じて、Pythonのさまざまなバージョンを効果的に管理して、プロジェクトのスムーズな実行を確保できます。

numpyarrayshaveveraladvantages-averstandardpythonarrays:1)thealmuchfasterduetocベースのインプレンテーション、2)アレモレメモリ効率、特にlargedatasets、および3)それらは、拡散化された、構造化された形成術科療法、


ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

VSCode Windows 64 ビットのダウンロード
Microsoft によって発売された無料で強力な IDE エディター

MinGW - Minimalist GNU for Windows
このプロジェクトは osdn.net/projects/mingw に移行中です。引き続きそこでフォローしていただけます。 MinGW: GNU Compiler Collection (GCC) のネイティブ Windows ポートであり、ネイティブ Windows アプリケーションを構築するための自由に配布可能なインポート ライブラリとヘッダー ファイルであり、C99 機能をサポートする MSVC ランタイムの拡張機能が含まれています。すべての MinGW ソフトウェアは 64 ビット Windows プラットフォームで実行できます。

EditPlus 中国語クラック版
サイズが小さく、構文の強調表示、コード プロンプト機能はサポートされていません

SAP NetWeaver Server Adapter for Eclipse
Eclipse を SAP NetWeaver アプリケーション サーバーと統合します。

Dreamweaver Mac版
ビジュアル Web 開発ツール

ホットトピック









